[Tutor] Plugin system - how to manage plugin files?
sirgnip at gmail.com
Wed Jul 28 20:53:42 CEST 2010
On Wed, Jul 28, 2010 at 10:07 AM, Mac Ryan <quasipedia at gmail.com> wrote:
> Hi everybody,
I don't know if this is exactly what you are after, but I created a
poor-man's plugin system by simply putting .py files into the same directory
as my app and naming them like xxxx_plugin.py Each of these .py "plugins",
had to define a class named "Plugin" that had some set of expected methods
and properties (ex: initialize(), run(), etc.). Then, when my app started
up, it simply got a list of all the "*_plugin.py" files in the current
directory, dynamically imported the files using "my_module =
__import__(name)" and then I could do whatever I wanted with that module
using "my_module", such as instantiate an object for each module's "Plugin"
Actually, here's a snippet of code I had lying around that I slapped
together a few years ago to remind myself of how I did this. I can't
promise this is 100% tested, but it should give you an idea.
Also, you might want to look at this discussion:
Best of luck!
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor