By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,621 Members | 1,101 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,621 IT Pros & Developers. It's quick & easy.

A question on plugin design

P: n/a
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
Aug 5 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Grzegorz Słodkowicz <je*****@wp.plwrites:
[...]
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
Aug 5 '07 #2

P: n/a
jj*@pobox.com (John J. Lee) writes:
Grzegorz Słodkowicz <je*****@wp.plwrites:
[...]
>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.
And as an example of a project that uses that plugin system, look at
the nose testing tool (I suggest looking at version 0.10, not version
0.9):

http://code.google.com/p/python-nose/
John
Aug 5 '07 #3

P: n/a
John J. Lee a écrit :
jj*@pobox.com (John J. Lee) writes:
>Grzegorz Słodkowicz <je*****@wp.plwrites:
[...]
>>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.

And as an example of a project that uses that plugin system, look at
the nose testing tool
And at Trac too.
Aug 6 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.