
* Brian Costlow <brian.costlow@gmail.com> [2007-04-04 10:37:20 -0400]:
# plugin class Foo(object): implements(IPlugin, imyplugins.IMyPlugIn)
def fooStuff(self): # do foo stuff
def fooFactory(self): return Foo()
f = Foo() # end plugin
#call plugin from app for n in getPlugins(imyplugins.IMyPlugIn): o = n.fooFactory() o.fooStuff()
Does this make sense? Is there a better way in the twisted framework to handle this?
The other replies to your posts raise some good points, but I would just like to point out that classes themselves can be used as plugins. For example: class Foo(object): classProvides(IPlugin, IMyPlugin): def fooStuff(self): """Does foo stuff.""" for cls in getPlugins(IMyPlugin): o = cls() o.fooStuff() -- mithrandi, i Ainil en-Balandor, a faer Ambar