Extension Manager

One of the most popular and missed Python’s features is a feature to work with extensions (plugins) and Dooku, as usual, provides this feature.


class dooku.ext.ExtensionManager(namespace, names=None, silent=False)

Load and manage your extensions with fun!

The class was designed to provide minimal functionality to interact with extension collections. In many ways it works similar to stevedore, but unlike the last one it operates with exported beings and doesn’t create instances for those beings.

Well, what it means for you? It means...

  • You can discover and load extensions from a given namespace.
  • You can get extension (exported being) by name.
  • You can iterate over discovered and loaded extensions.
  • You can check whether extension is loaded or not.

Behind the class lies an idea to discover extensions by means of entry_points. So the first thing you have to do is to declare your plugin in setup.py and then install it:

    # ...
        'my_plugin_namespace': [
            'plugin_name = my_package.my_plugin:MyPluginClass',

After plugin installation it becomes available for discovering and loading, so you probably want to get it:

from dooku.ext import ExtensionManager

for name, extension in ExtensionManager('my_plugin_namespace'):
    # name is plugin_name
    # extension is MyPluginClass

You also can load plugins selectively. Look at class parameters for details.

  • namespace – A namespace to import from as string.
  • names – A list of objects to import; imports all if None. If passed it specifies an order of imports.
  • silent – Skip loading errors if True; otherwise - throw exception.