supplemental data factory

S

sndive

i'm trying to import a module
typeinfo that looks like so:
import xml.dom import minidom

var mapper =
{
minidom.Element.__class__ : "Element",
minidom.Node.__class__ : "Node"
};

then i'd write a factory method that's look roughly like this:
addBaggage(PyObject *victim)
{
PyObject *typeinfo = PyImport_ImportModule("typeInfo");
PyObject *dict = PyObject_GetAttrString(pModule, "mapper");
PyObject *pclass = PyObject_GetAttrString( victim, "__class__");

PyObject *baggagename = PyDict_GetItem(dict, pclass);

then i'll convert baggagename into a char * and key
into a dictionary mapping char * to factory methods
or painstakingly if PyObject_IsInstance() else PyObject_IsInstance()
the whole thing (i'll have more than two entries in the mapper
and, possibly, beyond the minidom module)

for my classes. Is there a simpler way to accomplish what i'm trying
to do, for example leverage the existing metadata for minidom module?
I'm thinking maybe i can just specify a tuple of modules in
typeinfo instead and iterate on all classes in those modules.
lookups in the dictionary seem quicker though... thoughts?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top