A question on plugin design

Discussion in 'Python' started by =?UTF-8?B?R3J6ZWdvcnogU8WCb2Rrb3dpY3o=?=, Aug 5, 2007.

  1. 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
     
    =?UTF-8?B?R3J6ZWdvcnogU8WCb2Rrb3dpY3o=?=, Aug 5, 2007
    #1
    1. Advertising

  2. =?UTF-8?B?R3J6ZWdvcnogU8WCb2Rrb3dpY3o=?=

    John J. Lee Guest

    Grzegorz SÅ‚odkowicz <> writes:
    [...]
    > 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
     
    John J. Lee, Aug 5, 2007
    #2
    1. Advertising

  3. =?UTF-8?B?R3J6ZWdvcnogU8WCb2Rrb3dpY3o=?=

    John J. Lee Guest

    (John J. Lee) writes:

    > Grzegorz SÅ‚odkowicz <> writes:
    > [...]
    >> 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
     
    John J. Lee, Aug 5, 2007
    #3
  4. John J. Lee a écrit :
    > (John J. Lee) writes:
    >
    >> Grzegorz SÅ‚odkowicz <> writes:
    >> [...]
    >>> 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.
     
    Bruno Desthuilliers, Aug 6, 2007
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. PilotYid
    Replies:
    1
    Views:
    681
    Andrew Thompson
    Oct 31, 2005
  2. Marcin Cenkier
    Replies:
    1
    Views:
    5,506
    Marcin Cenkier
    Apr 12, 2006
  3. Jimmy
    Replies:
    0
    Views:
    549
    Jimmy
    Mar 15, 2007
  4. Replies:
    1
    Views:
    773
  5. Florian Weber

    how to design plugin functionality

    Florian Weber, Jun 16, 2004, in forum: Ruby
    Replies:
    7
    Views:
    168
    Richard Kilmer
    Jun 17, 2004
Loading...

Share This Page