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.

find_directory_plugins(directory, plugin_class=<class 'bag.web.pyramid.plugins_manager.BasePlugin'>)[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).


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

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