Package yapsy :: Module PluginManager :: Class PluginManagerDecorator
[hide private]

Class PluginManagerDecorator

source code

object --+
         |
        PluginManagerDecorator
Known Subclasses:
AutoInstallPluginManager.AutoInstallPluginManager, VersionedPluginManager.VersionedPluginManager, ConfigurablePluginManager.ConfigurablePluginManager

Make it possible to add several responsibilities to a plugin manager object in a more flexible way than by mere subclassing. This is indeed an implementation of the Decorator Design Patterns.

There is also an additional mechanism that allows for the automatic creation of the object to be decorated when this object is an instance of PluginManager (and not an instance of its subclasses). This way we can keep the plugin managers creation simple when the user don't want to mix a lot of 'enhancements' on the base class.



Instance Methods [hide private]
 
__init__(self, decorated_object=None, categories_filter={'Default': <class 'yapsy.IPlugin.IPlugin'>}, directories_list=['/home/thibauld/src/yapsy/yapsydir/trunk/yapsy'], plugin_info_ext='yapsy-plugin')
Mimics the PluginManager's __init__ method and wraps an instance of this class into this decorator class.
source code
 
__getattr__(self, name)
Decorator trick copied from: http://www.pasteur.fr/formation/infobio/python/ch18s06.html
source code
 
collectPlugins(self)
This function will usually be a shortcut to successively call self.locatePlugins and then self.loadPlugins which are very likely to be redefined in each new decorator.
source code

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

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, decorated_object=None, categories_filter={'Default': <class 'yapsy.IPlugin.IPlugin'>}, directories_list=['/home/thibauld/src/yapsy/yapsydir/trunk/yapsy'], plugin_info_ext='yapsy-plugin')
(Constructor)

source code 

Mimics the PluginManager's __init__ method and wraps an instance of this class into this decorator class.

  • If the decorated_object is not specified, then we use the PluginManager class to create the 'base' manager, and to do so we will use the arguments: categories_filter, directories_list, and plugin_info_ext or their default value if they are not given.
  • If the decorated object is given, these last arguments are simply ignored !

All classes (and especially subclasses of this one) that want to be a decorator must accept the decorated manager as an object passed to the init function under the exact keyword decorated_object.

Overrides: object.__init__

collectPlugins(self)

source code 

This function will usually be a shortcut to successively call self.locatePlugins and then self.loadPlugins which are very likely to be redefined in each new decorator.

So in order for this to keep on being a "shortcut" and not a real pain, I'm redefining it here.