dip.plugins.default_plugin_manager

The dip.plugins.plugin_manager module contains dip’s default plugin manager implementation.

PluginManager

class dip.plugins.default_plugin_manager.PluginManager

Base class: Model

The PluginManager class is the default implementation of the IPluginManager interface.

bind_extension_point(id, obj, name)

Bind an extension point to an attribute of an object. The attribute must have an append() method.

Parameters:
  • id – is the identifier of the extension point.
  • obj – is the object containing the attribute that the extension point is bound to.
  • name – is the name of the attribute that the extension point is bound to.
bind_service(interface, obj, name)

Bind the service for an interface to an attribute of an object.

Parameters:
  • interface – is the interface.
  • obj – is the object containing the attribute that the service is bound to.
  • name – is the name of the attribute that the service is bound to.
choose_service(services)

Choose a particular service from a list of possible services.

Parameters:services – a list of contributed services to choose from.
Returns:the chosen service or None if one wasn’t chosen.
contribute(id, contribution)

Contribute an object to an extension point.

Parameters:
  • id – is the identifier of the extension point.
  • contribution – is the contribution to make to the extension point.
service(interface)

Get a service for a particular interface.

Parameters:interface – is the interface.
Returns:the service which will implement or be able to be adapted to the interface. An exception is raised if there is no service available.