Package yapsy :: Module ConfigurablePluginManager :: Class ConfigurablePluginManager
[hide private]

Class ConfigurablePluginManager

source code

                          object --+    
                                   |    
PluginManager.PluginManagerDecorator --+
                                       |
                                      ConfigurablePluginManager

A plugin manager that also manages a configuration file.

The configuration file will be accessed through a ConfigParser derivated object. The file can be used for other purpose by the application using this plugin manager as it will only add a new specific section [Plugin Management] for itself and also new sections for some plugins that will start with [Plugin:...] (only the plugins that explicitly requires to save configuration options will have this kind of section).

Warning

when giving/building the list of plugins to activate by default, there must not be any space in the list (neither in the names nor in between)



Instance Methods [hide private]
 
__init__(self, configparser_instance=None, config_change_trigger=<function <lambda> at 0xe4ce60>, decorated_manager=None, categories_filter={'Default': <class 'yapsy.IPlugin.IPlugin'>}, directories_list=None, plugin_info_ext='yapsy-plugin')
Create the plugin manager and record the ConfigParser instance that will be used afterwards.
source code
 
setConfigParser(self, configparser_instance, config_change_trigger)
Set the ConfigParser instance.
source code
 
__getCategoryPluginsListFromConfig(self, plugin_list_str)
Parse the string describing the list of plugins to activate, to discover their actual names and return them.
source code
 
__getCategoryPluginsConfigFromList(self, plugin_list)
Compose a string describing the list of plugins to activate
source code
 
__getCategoryOptionsName(self, category_name)
Return the appropirately formated version of the category's option.
source code
 
__addPluginToConfig(self, category_name, plugin_name)
Utility function to add a plugin to the list of plugin to be activated.
source code
 
__removePluginFromConfig(self, category_name, plugin_name)
Utility function to add a plugin to the list of plugin to be activated.
source code
 
registerOptionFromPlugin(self, category_name, plugin_name, option_name, option_value)
To be called from a plugin object, register a given option in the name of a given plugin.
source code
 
hasOptionFromPlugin(self, category_name, plugin_name, option_name)
To be called from a plugin object, return True if the option has already been registered.
source code
 
readOptionFromPlugin(self, category_name, plugin_name, option_name)
To be called from a plugin object, read a given option in the name of a given plugin.
source code
 
__decoratePluginObject(self, category_name, plugin_name, plugin_object)
Add two methods to the plugin objects that will make it possible for it to benefit from this class's api concerning the management of the options.
source code
 
activatePluginByName(self, plugin_name, category_name='Default', save_state=True)
Activate a plugin, , and remember it (in the config file).
source code
 
deactivatePluginByName(self, plugin_name, category_name='Default', save_state=True)
Deactivate a plugin, and remember it (in the config file).
source code
 
loadPlugins(self, callback=None)
Walk through the plugins' places and look for plugins.
source code

Inherited from PluginManager.PluginManagerDecorator: __getattr__, collectPlugins

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

Class Variables [hide private]
  CONFIG_SECTION_NAME = 'Plugin Management'
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, configparser_instance=None, config_change_trigger=<function <lambda> at 0xe4ce60>, decorated_manager=None, categories_filter={'Default': <class 'yapsy.IPlugin.IPlugin'>}, directories_list=None, plugin_info_ext='yapsy-plugin')
(Constructor)

source code 

Create the plugin manager and record the ConfigParser instance that will be used afterwards.

The config_change_trigger argument can be used to set a specific method to call when the configuration is altered. This will let the client application manage the way they want the configuration to be updated (e.g. write on file at each change or at precise time intervalls or whatever....)

Overrides: PluginManager.PluginManagerDecorator.__init__

activatePluginByName(self, plugin_name, category_name='Default', save_state=True)

source code 

Activate a plugin, , and remember it (in the config file).

If you want the plugin to benefit from the configuration utility defined by this manager, it is crucial to use this method to activate a plugin and not call the plugin object's activate method. In fact, this method will also "decorate" the plugin object so that it can use this class's methods to register its own options.

By default, the plugin's activation is registered in the config file but if you d'ont want this set the 'save_state' argument to False.

deactivatePluginByName(self, plugin_name, category_name='Default', save_state=True)

source code 

Deactivate a plugin, and remember it (in the config file).

By default, the plugin's deactivation is registered in the config file but if you d'ont want this set the save_state argument to False.

loadPlugins(self, callback=None)

source code 
Walk through the plugins' places and look for plugins. Then for each plugin candidate look for its category, load it and stores it in the appropriate slot of the category_mapping.