S
Simon Roses Femerling
Dear pythonnians
Hopeful somebody can help me about implementing plugin support.
I'm working on a python/wxpython app that needs plugin support. My problem is:
The way my app works is a python module (plugin) that contains (imbedded) XML defining
the classname and some extra information and the app will be load the module using the classname:
Example:
------ mymodule.py ----
__xml__ ="""
<data>
<classname>Test</classname>
</data>
"""
class Test:
def Msg(self):
print "Hello"
---------------------------------
--- MyApp.py -----------
fp = open(f)
exec(fp) in globals()
str = __xml__
pxml = parsexml.ParseXML()
pxml.BeginParse(str)
cn = pxml.GetClassname()
mymod = cn() <-- Here is the error
mymod.Msg()
----------------------------------
The error is:
Traceback (most recent call last):
File "blackout.py", line 503, in onAttackMod
mymod = cn()
TypeError: 'unicode' object is not callable
Any suggestions ? How can achieve this ?
Each module (plugin) can have a different class name defined in the XML data.
Besides this anyone have suggestions for a better plugin framework ? Maybe using imp module to dynamically import
modules ?
Any examples ?
Thx for any help!
Sincerely
SRF
Hopeful somebody can help me about implementing plugin support.
I'm working on a python/wxpython app that needs plugin support. My problem is:
The way my app works is a python module (plugin) that contains (imbedded) XML defining
the classname and some extra information and the app will be load the module using the classname:
Example:
------ mymodule.py ----
__xml__ ="""
<data>
<classname>Test</classname>
</data>
"""
class Test:
def Msg(self):
print "Hello"
---------------------------------
--- MyApp.py -----------
fp = open(f)
exec(fp) in globals()
str = __xml__
pxml = parsexml.ParseXML()
pxml.BeginParse(str)
cn = pxml.GetClassname()
mymod = cn() <-- Here is the error
mymod.Msg()
----------------------------------
The error is:
Traceback (most recent call last):
File "blackout.py", line 503, in onAttackMod
mymod = cn()
TypeError: 'unicode' object is not callable
Any suggestions ? How can achieve this ?
Each module (plugin) can have a different class name defined in the XML data.
Besides this anyone have suggestions for a better plugin framework ? Maybe using imp module to dynamically import
modules ?
Any examples ?
Thx for any help!
Sincerely
SRF