Go to the documentation of this file.00001
00002
00003
00004
00005 TheXmlResource = XmlResource_Get()
00006
00007
00008
00009
00010
00011
00012 def _my_import(name):
00013 try:
00014 mod = __import__(name)
00015 except ImportError:
00016 import traceback
00017 print traceback.format_exc()
00018 raise
00019 components = name.split('.')
00020 for comp in components[1:]:
00021 mod = getattr(mod, comp)
00022 return mod
00023
00024
00025 class XmlSubclassFactory_Python(XmlSubclassFactory):
00026 def __init__(self):
00027 XmlSubclassFactory.__init__(self)
00028
00029 def Create(self, className):
00030 assert className.find('.') != -1, "Module name must be specified!"
00031 mname = className[:className.rfind('.')]
00032 cname = className[className.rfind('.')+1:]
00033 module = _my_import(mname)
00034 klass = getattr(module, cname)
00035 inst = klass()
00036 return inst
00037
00038
00039 XmlResource_AddSubclassFactory(XmlSubclassFactory_Python())
00040
00041