dip.plugins
¶
The dip.plugins
module implements the infrastructure for
encapsulating application plugins.
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
(contribution)¶ Contribute an object to all bound attributes.
Parameters: contribution – is the object 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
(contribution)¶ Contribute an object to all bound attributes.
Parameters: contribution – is the object to contribute.
-
IPlugin
¶
-
class
dip.plugins.
IPlugin
¶ Base class:
Interface
The IPlugin interface defines the API of a plugin.
-
enabled = Bool(True)
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.
-
requires = List(Str())
The list of identifiers of plugins that must be enabled before this one can be enabled.
-
configure
(plugin_manager)¶ This is called when the plugin is enabled to ask that it configures itself.
Parameters: plugin_manager – the plugin manager.
-
IPluginManager
¶
-
class
dip.plugins.
IPluginManager
¶ Base class:
Interface
The IPluginManager interface defines the API of a plugin manager.
-
extension_points = List(IExtensionPoint)
The list of extension points.
-
plugins = List(IPlugin)
The list of contributed plugins.
-
services = List(IService)
The list of contributed services.
-
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.
-
PluginManager
¶
-
class
dip.plugins.
PluginManager
¶ Base class:
Singleton
The PluginManager class is a singleton that provides access to a default plugin manager.
-
instance = Instance(IPluginManager)
The plugin manager instance.
-
classmethod
add_plugin
(plugin)¶ Add a plugin to the plugin manager.
Parameters: plugin – is the plugin.
-