2003-11-12 16:34:20 -05:00
|
|
|
#----------------------------------------------------------------------------
|
2002-01-21 22:22:03 -05:00
|
|
|
# The global was removed in favor of static accessor functions. This is for
|
|
|
|
# backwards compatibility:
|
2003-03-25 01:35:27 -05:00
|
|
|
|
2003-11-12 16:34:20 -05:00
|
|
|
TheXmlResource = XmlResource_Get()
|
2003-03-25 01:35:27 -05:00
|
|
|
|
|
|
|
|
2003-11-12 16:34:20 -05:00
|
|
|
#----------------------------------------------------------------------------
|
2003-03-25 01:35:27 -05:00
|
|
|
# Create a factory for handling the subclass property of the object tag.
|
|
|
|
|
|
|
|
|
|
|
|
def _my_import(name):
|
|
|
|
mod = __import__(name)
|
|
|
|
components = name.split('.')
|
|
|
|
for comp in components[1:]:
|
|
|
|
mod = getattr(mod, comp)
|
|
|
|
return mod
|
|
|
|
|
|
|
|
|
2003-11-12 16:34:20 -05:00
|
|
|
class XmlSubclassFactory_Python(XmlSubclassFactory):
|
2003-03-25 01:35:27 -05:00
|
|
|
def __init__(self):
|
2003-11-12 16:34:20 -05:00
|
|
|
XmlSubclassFactory.__init__(self)
|
2003-03-25 01:35:27 -05:00
|
|
|
|
|
|
|
def Create(self, className):
|
|
|
|
assert className.find('.') != -1, "Module name must be specified!"
|
|
|
|
mname = className[:className.rfind('.')]
|
|
|
|
cname = className[className.rfind('.')+1:]
|
|
|
|
module = _my_import(mname)
|
|
|
|
klass = getattr(module, cname)
|
|
|
|
inst = klass()
|
|
|
|
return inst
|
|
|
|
|
|
|
|
|
2003-11-12 16:34:20 -05:00
|
|
|
XmlResource_AddSubclassFactory(XmlSubclassFactory_Python())
|
2003-03-25 01:35:27 -05:00
|
|
|
|
2003-11-12 16:34:20 -05:00
|
|
|
#----------------------------------------------------------------------------
|