A question on plugin design

G

Guest

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
 
J

John J. Lee

Grzegorz SÅ‚odkowicz said:
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.

Google for setuptools and Python eggs. Search for "entry point" on
the setuptools page.


John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top