Package elisa :: Package core :: Module plugin_registry :: Class PluginRegistry

Class PluginRegistry

source code


The plugin registry is responsible for finding, loading, downloading, enabling plugins and providing facilities to access their contents and properties.

New plugins can be developed outside of Moovida's code to provide new functionalities. Base classes are defined to standardize common functionalities that are likely to be reused.

DOCME more.

Instance Methods
 
__init__(self, config=None, plugin_dirs=None)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
load_plugins(self, disabled_plugins=[])
Load plugins from self.plugin_dirs.
source code
 
load_plugin(self, plugin)
Load a given plugin in elisa.
source code
twisted.internet.defer.Deferred
unload_plugin(self, plugin)
Unload a given plugin from elisa.
source code
 
register_plugin_status_changed_callback(self, callback)
Register a callback to be fired upon (de)activation of a plugin.
source code
 
unregister_plugin_status_changed_callback(self, callback)
Unregister a callback that was previously registered to be fired upon (de)activation of a plugin.
source code
twisted.internet.defer.Deferred
enable_plugins(self)
Enable all the plugins that should be enabled.
source code
twisted.internet.defer.Deferred
enable_plugin(self, plugin_name)
Enable a plugin.
source code
twisted.internet.defer.Deferred
disable_plugin(self, plugin_name, permanent=False)
Disable a plugin.
source code
generator
get_plugins(self)
Get the list of available plugins.
source code
generator
get_enabled_plugins(self)
Get the list of enabled plugins.
source code
generator
get_plugin_names(self)
Get the names of the installed plugins.
source code
pkg_resources.Distribution
get_plugin_by_name(self, plugin_name)
Return the plugin matching a given name.
source code
 
get_plugin_metadata(self, plugin)
Read and populate the metadata of a plugin.
source code
 
plugin_cache(self) source code
 
plugin_repository(self) source code
bool
reload_cache(self)
Load the cached information about downloadable plugins.
source code
elisa.core.utils.defer.Deferred
update_cache(self)
Update the cached information about downloadable plugins.
source code
list
get_downloadable_plugins(self, reload_cache=False)
The list of downloadable plugins.
source code
elisa.core.utils.defer.Deferred
download_plugin(self, plugin)
Download one plugin.
source code
elisa.core.utils.defer.Deferred
install_plugin(self, egg_file, plugin_name)
Install a plugin from a local egg file.
source code
elisa.core.utils.defer.Deferred
update_plugin(self, plugin_dict)
Update an installed plugin for which a newer version is available in the plugin repository.
source code
elisa.core.utils.defer.Deferred
install_new_recommended_plugins(self)
Download and install all the recommended plugins.
source code
elisa.core.component.Component or a subclass
create_component(self, path, config=None, **kwargs)
Create a component given its path.
source code

Inherited from extern.log.log.Loggable: debug, doLog, error, info, log, logFunction, logObjectName, warning, warningFailure

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables
  config_section_name = 'plugin_registry'
  default_config = {'repository': 'http://plugins.moovida.com/pl...
  config_doc = {'repository': 'The plugin repository to query fo...

Inherited from extern.log.log.Loggable: logCategory

Properties

Inherited from object: __class__

Method Details

__init__(self, config=None, plugin_dirs=None)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)

load_plugins(self, disabled_plugins=[])

source code 

Load plugins from self.plugin_dirs.

Parameters:
  • disabled_plugins (list of str) - a list of plugins that should be disabled

Attention: This function should be called as early as possible at startup, before using any plugin.

Notes:
  • This function runs without returning to the reactor for as long as it takes. There is no point in making it return before it is done as the plugin environment needs to be set up before any other part of elisa can run correctly.
  • By default, all the available plugins are enabled.

load_plugin(self, plugin)

source code 

Load a given plugin in elisa.

Parameters:

unload_plugin(self, plugin)

source code 

Unload a given plugin from elisa.

Parameters:
Returns: twisted.internet.defer.Deferred
a deferred fired when the plugin is fully unloaded

register_plugin_status_changed_callback(self, callback)

source code 

Register a callback to be fired upon (de)activation of a plugin. This callback will be passed the plugin (pkg_resources.Distribution) and the new status (bool, True for enabled, False for disabled) as parameters, and should return a deferred. The plugin status will be considered as changed (and the corresponding message emitted) only when all the resulting deferreds of the registered callbacks have fired (or errored).

Parameters:
  • callback (callable) - a callback

unregister_plugin_status_changed_callback(self, callback)

source code 

Unregister a callback that was previously registered to be fired upon (de)activation of a plugin.

Parameters:
  • callback (callable) - a callback previously registered
Raises:
  • ValueError - if the callback is not registered

enable_plugins(self)

source code 

Enable all the plugins that should be enabled.

Returns: twisted.internet.defer.Deferred
a deferred fired when all plugins have been enabled

Attention: this method can be called only once and should be called upon startup of the application, after load_plugins.

enable_plugin(self, plugin_name)

source code 

Enable a plugin.

Parameters:
  • plugin_name (str) - the name of the plugin to enable
Returns: twisted.internet.defer.Deferred
a deferred fired when the plugin is enabled

disable_plugin(self, plugin_name, permanent=False)

source code 

Disable a plugin.

Parameters:
  • plugin_name (str) - the name of the plugin to disable
  • permanent (bool) - whether the plugin should be disabled permanently (in the configuration), or only for this run
Returns: twisted.internet.defer.Deferred
a deferred fired when the plugin is disabled

get_plugins(self)

source code 

Get the list of available plugins.

This call returns (plugin_name, status) tuples, where status is True if the plugin is enabled, False otherwise.

Returns: generator
a generator yielding (plugin_name, status) tuples

get_enabled_plugins(self)

source code 

Get the list of enabled plugins.

Returns: generator
generator yielding plugin names

get_plugin_names(self)

source code 

Get the names of the installed plugins.

Returns: generator
a generator yielding plugin names

get_plugin_by_name(self, plugin_name)

source code 

Return the plugin matching a given name.

Parameters:
  • plugin_name (str) - the name of the plugin
Returns: pkg_resources.Distribution
the plugin, or None if no plugin matches the given name

get_plugin_metadata(self, plugin)

source code 

Read and populate the metadata of a plugin.

Parameters:

plugin_cache(self)

source code 
Decorators:
  • @property

plugin_repository(self)

source code 
Decorators:
  • @property

reload_cache(self)

source code 

Load the cached information about downloadable plugins.

Returns: bool
whether the loading went well.

update_cache(self)

source code 

Update the cached information about downloadable plugins.

At present only one remote, hardcoded repository is supported.

Returns: elisa.core.utils.defer.Deferred
a deferred triggered when the cache is updated

get_downloadable_plugins(self, reload_cache=False)

source code 

The list of downloadable plugins.

Each plugin is represented as a Python dictionary.

Parameters:
  • reload_cache (bool) - whether to reload the local cache from disk
Returns: list
a list of one dict per plugin.

download_plugin(self, plugin)

source code 

Download one plugin.

A plugin is represented with a dictionary. Some expected keys are listed at http://www.moovida.com/wiki/Specs/PluginsMetadata. Here we just rely on 'egg_name' and 'uri'. If they change, this code will simply break.

Parameters:
  • plugin (dict) - the plugin dictionary
Returns: elisa.core.utils.defer.Deferred
a deferred triggered when done, reporting the path to the downloaded egg file

install_plugin(self, egg_file, plugin_name)

source code 

Install a plugin from a local egg file.

If needed, the egg file will be copied over to the local plugins directory and the older version of the plugin will be unloaded. The plugin will then be loaded and enabled.

Parameters:
  • egg_file (str) - the full path to the egg file on disk
  • plugin_name (str) - the internal name of the plugin
Returns: elisa.core.utils.defer.Deferred
a deferred fired when the plugin is installed

update_plugin(self, plugin_dict)

source code 

Update an installed plugin for which a newer version is available in the plugin repository.

Updating a plugin will disable the current version if needed, unload it, download the new version, load it and enable it.

Parameters:
Returns: elisa.core.utils.defer.Deferred
a deferred fired when the update is complete

Attention: this code assumes that the plugin to update is currently installed and that the plugin repository actually provides a newer version. Behaviour outside of these constraints is undefined.

install_new_recommended_plugins(self)

source code 

Download and install all the recommended plugins.

This will typically happen when first running Elisa after installation, if the user selected the 'Install Recommended Plugins' option in the installer.

Returns: elisa.core.utils.defer.Deferred
a deferred fired when the installation is complete

create_component(self, path, config=None, **kwargs)

source code 

Create a component given its path.

The path is in module:Component syntax, eg elisa.plugins.my_plugin:MyComponent.

Parameters:
Returns: elisa.core.component.Component or a subclass
an instance of the component identified by path

Class Variable Details

default_config

Value:
{'repository': 'http://plugins.moovida.com/plugin_list', 'update_plugi\
n_cache': True, 'auto_update_plugins': True, 'auto_install_new_recomme\
nded_plugins': True}

config_doc

Value:
{'repository': 'The plugin repository to query for new plugins and ' '\
plugin updates.', 'update_plugin_cache': 'Whether to periodically quer\
y the plugin ' 'repository to update the plugin cache. If False, autom\
atic ' 'plugin updates and downloading of new recommended plugins will\
 ' 'be deactivated.', 'auto_update_plugins': 'Whether to silently inst\
all all available ' 'plugin updates. Ignored if update_plugin_cache is\
 False.', 'auto_install_new_recommended_plugins': 'Whether to silently\
 ' 'install all new recommended plugins available. Ignored if ' 'updat\
...