PyXWF.Registry – Metaclass magic for registering plugins

Note

You don’t need to know in detail what this module does and how it works to develop plugins.

This is the heart of the painless plugin registration feature of PyXWF. Herein defined are the metaclasses responsible for validating and registering plugin classes and the registries themselves.

class PyXWF.Registry.CrumbMeta[source]

Takes abc.ABCMeta and mixes it with the NamespaceMetaMixin to create a suitable Crumb plugin metaclass.

Note

See CrumbBase for an example of use.

class PyXWF.Registry.NamespaceMetaMixin[source]

Mixin for a metaclass which handles registration of classes which register based on namespace/tag name pairs.

It requires that the class has a namespace attribute which has to be a valid XML namespace as a string and a names attribute which must be an iterable of strings which must all be valid XML node tags.

The class will be registered for all names in the given namespace.

class PyXWF.Registry.NamespaceRegistry[source]

A more specialized baseclass for registries dealing with namespace/tagname pairs for XML nodes.

register(ns, names, cls)[source]

Register the class cls for all names in names with namespace ns.

class PyXWF.Registry.NodeMeta[source]

Takes NodeMeta and mixes it with the NamespaceMetaMixin to create a suitable Node plugin metaclass.

Note

See Node for an example of use.

class PyXWF.Registry.RegistryBase[source]

Base class for the registries defined herein. An end user will never have to do anything with these classes.

Developers may want to subclass this one if they really need to introduce a new registry to PyXWF.

register_multiple(keys, cls)[source]

Iterate over keys and set each key to cls in self.

class PyXWF.Registry.SitletonMeta[source]

A class using this metaclass will have exactly one instance per running site. Thus, this metaclass is useful for use with hook classes which register hooks on a site and do nothing else.

Previous topic

Plugin framework

Next topic

PyXWF.Sitleton – One instance per site

This Page