apptools.persistence.version_registry module

A version registry that manages handlers for different state versions.

class apptools.persistence.version_registry.HandlerRegistry[source]

Bases: object

A simple version conversion handler registry. Classes register handlers in order to convert the state version to the latest version. When an object’s state is about to be set, the update method of the registy is called. This in turn calls any handlers registered for the class/module and this handler is then called with the state and the version of the state. The state is modified in-place by the handlers.

register(class_name, module, handler)[source]

Register handler that handles versioning for class having class name (class_name) and module name (module). The handler function will be passed the state and its version to fix.

unregister(class_name, module)[source]

Unregisters any handlers for a class and module.

update(state)[source]

Updates the given state using the handlers. Note that the state is modified in-place.

apptools.persistence.version_registry.get_version(obj)[source]

Walks the class hierarchy and obtains the versions of the various classes and returns a list of tuples of the form ((class_name, module), version) in reverse order of the MRO.