bag.web.pyramid.plugins_manager module

Manage plugins for your Python software.

class bag.web.pyramid.plugins_manager.BasePlugin[source]

Bases: object

Marker class for plugins.

class bag.web.pyramid.plugins_manager.PluginsManager(settings)[source]

Bases: object

add_plugin(callable, module_name)[source]

Instantiates a plugin and stores it if its name is new.

call(method, args=[], kwargs={}, only_enabled_plugins=True)[source]

Generic method that calls some method in the plugins.

enabled[source]
find_directory_plugins(directory, plugin_class=<class 'bag.web.pyramid.plugins_manager.BasePlugin'>)[source]
find_egg_plugins(entry_point_groups)[source]
is_enabled(name)[source]
bag.web.pyramid.plugins_manager.find_subclasses(cls, path)[source]

Find subclasses of cls in .py files located below path.

(This does look in subdirectories).

Usage:

classes = find_subclasses(BasePlugin, "pluginsfolder")

@param cls: the base class that all subclasses should inherit from @type cls: class @param path: the path to the top level directory to walk @type path: str @rtype: list @return: a list if classes that are subclasses of cls

Stolen from http://www.luckydonkey.com/2008/01/02/python-style-plugins-made-easy/

This could be improved by using cls.__subclasses__(), however this only returns the immediate subclasses.