cement.ext.ext_plugin

The Plugin Extension handles application plugin support, and is the default plugin handler used by Cement.

Requirements

  • No external dependencies

Configuration

This extension does not directly honor any configuration settings.

Usage

For usage information see Application Plugins.

class cement.ext.ext_plugin.CementPluginHandler

Bases: cement.core.plugin.CementPluginHandler

This class is an internal implementation of the IPlugin interface. It does not take any parameters on initialization.

class Meta

Bases: object

Handler meta-data.

interface

The interface that this class implements.

alias of IPlugin

label = 'cement'

The string identifier for this class.

CementPluginHandler._load_plugin_from_bootstrap(plugin_name, base_package)

Load a plugin from a python package. Returns True if no ImportError is encountered.

Parameters:
  • plugin_name (str) – The name of the plugin, also the name of the module to load from base_package. I.e. myapp.bootstrap.myplugin
  • base_package (str) – The base python package to load the plugin module from. I.e.’myapp.bootstrap’ or similar.
Returns:

True is the plugin was loaded, False otherwise

Raises:

ImportError

CementPluginHandler._load_plugin_from_dir(plugin_name, plugin_dir)

Load a plugin from a directory path rather than a python package within sys.path. This would either be myplugin.py or myplugin/__init__.py within the given plugin_dir.

Parameters:
  • plugin_name – The name of the plugin.
  • plugin_dir – The filesystem directory path where the plugin exists.
CementPluginHandler.get_disabled_plugins()

List of disabled plugins

CementPluginHandler.get_enabled_plugins()

List of plugins that are enabled (not necessary loaded yet).

CementPluginHandler.get_loaded_plugins()

List of plugins that have been loaded.

CementPluginHandler.load_plugin(plugin_name)

Load a plugin whose name is plugin_name. First attempt to load from a plugin directory (plugin_dir), secondly attempt to load from a bootstrap module (plugin_bootstrap) determined by CementApp.Meta.plugin_bootstrap.

Upon successful loading of a plugin, the plugin name is appended to the self._loaded_plugins list.

Parameters:plugin_name (str) – The name of the plugin to load.
Raises:cement.core.exc.FrameworkError
CementPluginHandler.load_plugins(plugin_list)

Load a list of plugins. Each plugin name is passed to self.load_plugin().

Parameters:plugin_list – A list of plugin names to load.