Plugins

Dependency Injection Micro-Framework using Plugins

A Plugin provides some custom behaviour to specific Concrete classes in the class hierarchy The Base class of the hierarchy generally applies the plugins by adding PluginManager as a mixin Plugins can then be injected into any concrete class in its hierarchy.
class document_catalogue.plugins.AbstractViewPlugin[source]

Defines the API for a plugin that injects behaviour into a View class

apply(request)[source]

Apply the plugin to the given request just prior to dispatching it

extend_qs(request, qs)[source]

Extend, modify, or constrain the base document queryset and return it

get_context(request)[source]

Return a dictionary to be added to the View’s context

class document_catalogue.plugins.OrderedViewPlugin(query_param='dc_ordering')[source]

Applies ordering to view’s queryset based on URL query argument found in request.GET

extend_qs(request, qs)[source]

Extend, modify, or constrain the base document queryset and return it

get_context(request)[source]

Return a dictionary to be added to the View’s context

get_ordering(request)[source]

Return the order_by experession for the queryset

class document_catalogue.plugins.PluginManager[source]

A simple, generic plugin manager. Provides a clean dependency injection mechanism when used as a Mixin: BaseClass(PluginManager) BaseClass implements behaviours for plugins (defined by whatever interface suited to app) ConcreteSubclass(BaseClass) can then RegisterPlugins to inject additional behaviours

classmethod apply_plugins(f)[source]

Apply f to each plugin. f must be a callable that takes a single plugin parameter

class document_catalogue.plugins.RegisterPlugins(*plugins)[source]

A Decorator for registering a set of plugins to a PluginManager E.g.: @RegisterPlugins(Plugin1(some, parameters), Plugin2())

class document_catalogue.plugins.SessionOrderedViewPlugin(query_param='dc_ordering')[source]

Applies ordering to view’s queryset based on ordering passed in URL query arg and stored in session

apply(request)[source]

Apply the plugin to the given request

class document_catalogue.plugins.ViewPluginManager[source]

Encapsulates logic specific to applying AbstractViewPlugin plugins. Intended as View mixin

classmethod plugins_extend_qs(request, qs)[source]

Apply each plugin to the given queryset, in sequence, return resulting queryset