A question on plugin design

Grzegorz Słodkowicz jergosh at wp.pl
Sun Aug 5 07:09:46 EDT 2007


I'm working on my little project (an IM client) which I wanted to 
support plugins. My idea was that the core program would by itself do 
virtually nothing but manage plugins and all functionality would be 
provided by the plugins themselves (including protocol handling and UI. 
My first attempt was to check a directory for *.py files, execfile() 
them and rely on them to call a method to register a plugin object. This 
approach led to some conundrums and I discarded the it as bad design. My 
second take was to __import__() from each plugin file the plugin object 
and append it to a list of all plugins. But, this way I have to put 
imports into the __init__() of the plugin object or else they have no 
effect. Is this a valid approach? I'm starting to think that such 
problems are again symptoms of poor design.

I'd also be grateful for pointers to a well designed Pythonic plugin 
architecture but I'd much prefer a small project with a simple API.

TIA,
Greg Slodkowicz



More information about the Python-list mailing list