plugin development best practices

Jean-Paul Calderone exarkun at divmod.com
Thu Feb 22 10:06:14 EST 2007


On Thu, 22 Feb 2007 15:36:42 +0100, "Diez B. Roggisch" <deets at nospam.web.de> wrote:
>> Simple plugin system proposal:
>>
>> have a package (directory with __init__.py) called plugins where the
>> actual plugins are modules in this directory.
>>
>> When the main script imports the plugins package, all plugin modules
>> would be available as plugins.pluginA, plugins.pluginB , etc.
>>
>> A registry of available plugins would be available as a simple
>> dir(plugins).
>>
>> code in the main script than wished to use a given plugin, would only
>> have to look in the registry  before calling any code from a given
>> plugin.
>>
>> What is wrong/missing with this simple framework?
>
>Nothing wrong.

Are you sure?

  exarkun at charm:~$ mkdir someplugins
  exarkun at charm:~$ touch someplugins/__init__.py
  exarkun at charm:~$ touch someplugins/a.py
  exarkun at charm:~$ python
  Python 2.4.3 (#2, Oct  6 2006, 07:52:30)
  [GCC 4.0.3 (Ubuntu 4.0.3-1ubuntu5)] on linux2
  Type "help", "copyright", "credits" or "license" for more information.
  >>> import someplugins
  >>> dir(someplugins)
  ['__builtins__', '__doc__', '__file__', '__name__', '__path__']
  >>>

Hey, where's my plugin?

This most trivial test would have demonstrated the problem with the proposed
plugin system.  But I suppose it was easier for Flavio to make someone else
find the defect in his new system than to either test it himself or to look
carefully at any of the existing systems.

Jean-Paul



More information about the Python-list mailing list