dip.plugins

The dip.plugins module implements the infrastructure for encapsulating application plugins.

ContributionTo

class dip.plugins.ContributionTo

Base class: List

The ContributionTo class encapsulates a list of contributions to an extension point as an attribute of a plugin. The value is normally set using a computed default value.

__init__(id, **metadata)

Initialise the object.

Parameters:
  • id – is the identifier of the extension point.
  • **metadata – is additional meta-data stored with the type.
clone(default)

Create a clone of this instance with a different default value.

Parameter:default – is the default value of the cloned instance.
Returns:the cloned instance.

ExtensionPoint

class dip.plugins.ExtensionPoint

Base class: Model

The ExtensionPoint class is the default implementation of an extension point.

bind(obj, name)

Bind an attribute of an object to the extension point and update it with all contributions made so far.

Parameters:
  • obj – is the object containing the attribute to bind to.
  • name – is the name of the attribute to bind to.
contribute(contributions)

Contribute a list of objects to all bound attributes.

Parameter:contributions – is the list of objects to contribute.

IExtensionPoint

class dip.plugins.IExtensionPoint

Base class: Interface

The IExtensionPoint interface defines the API of an extension point.

contributions = List()
The list of contributions made.
id = Str()
The identifier of the extension point.
bind(obj, name)

Bind an attribute of an object to the extension point and update it with all contributions made so far.

Parameters:
  • obj – is the object containing the attribute to bind to.
  • name – is the name of the attribute to bind to.
contribute(contributions)

Contribute a list of objects to all bound attributes.

Parameter:contributions – is the list of objects to contribute.

IPlugin

class dip.plugins.IPlugin

Base class: Interface

The IPlugin interface defines the API of a plugin.

description = Str()
The description of the plugin as it will appear to the user.
enabled = Bool(False)
This is set if the plugin is enabled.
id = Str()
The identifier of the plugin. Two plugins are considered equivalent if their factories have the same identifier, even though the factories themselves are different.
plugin_manager = Instance(IPluginManager)
The plugin manager that is managing this plugin. It will be set by the plugin manager when the plugin is registered.
bind_extension_point(id, obj, name)

Bind an extension point to the 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.
enable()
The plugin is enabled. It should not be called if it is already enabled.
service(interface)

Get a service that implements a particular interface.

Parameter:interface – is the interface that the service must implement.
Returns:the service. An exception is raised if there is no service available.

IPluginManager

class dip.plugins.IPluginManager

Base class: Interface

The IPluginManager interface defines the API of a plugin manager.

bind_extension_point(id, obj, name)

Bind an extension point to the 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.
choose_service(interface, services)

Choose a particular service from a list of possible services.

Parameters:
  • interface – is the interface that the service must implement.
  • services – a list of contributed services to choose from. This can be ignored.
Returns:

the chosen service or None if one wasn’t chosen.

contribute(id, *contributions)

Contribute some objects to an extension point.

Parameters:
  • id – is the identifier of the extension point.
  • *contributions – are the contributions to make to the extension point. The contributions are made one at a time.
enable_plugins()
All plugins that are not already enabled are enabled.
service(interface)

Get a service that implements a particular interface.

Parameter:interface – is the interface that the service must implement.
Returns:the service. An exception is raised if there is no service available.

IService

class dip.plugins.IService

Base class: Interface

The IService interface defines the API of a service definition.

interface = Subclass(Interface)
The interface that the service implements.
implementation = Any()
The service implementation.

Plugin

class dip.plugins.Plugin

Base class: Model

The Plugin class is a convenience base class for a plugin.

bind_extension_point(id, obj, name)

Bind an extension point to the 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.
contributions()

This is called when the plugin is enabled to return an iterator of 2-tuples of the extension point identifier and the list of contributions to the extension point. This default implementation looks for any ContributionTo attributes in the plugin and its super-classes.

Returns:the iterator.
enable()
The plugin is enabled. It should not be called if it is already enabled.
service(interface)

Get a service that implements a particular interface.

Parameter:interface – is the interface that the service must implement.
Returns:the service. An exception is raised if there is no service available.

PluginManager

class dip.plugins.PluginManager

Base class: Model

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

__init__()
Initialise the plugin manager.
bind_extension_point(id, obj, name)

Bind an extension point to the 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.
choose_service(interface, services)

Choose a particular service from a list of possible services.

Parameters:
  • interface – is the interface that the service must implement.
  • services – a list of contributed services to choose from. This can be ignored.
Returns:

the chosen service or None if one wasn’t chosen.

contribute(id, *contributions)

Contribute some objects to an extension point.

Parameters:
  • id – is the identifier of the extension point.
  • *contributions – are the contributions to make to the extension point. The contributions are made one at a time.
enable_plugins()
All plugins that are not already enabled are enabled.
service(interface)

Get a service that implements a particular interface.

Parameter:interface – is the interface that the service must implement.
Returns:the service. An exception is raised if there is no service available.

Service

class dip.plugins.Service

Base class: Model

The Service class is the default implementation of a service definition.

Table Of Contents

Previous topic

dip.model

Next topic

dip.shell

This Page