assembl.lib.history_mixin module

Mixin classes for keeping old versions of data structures

class assembl.lib.history_mixin.Dehistoricizer(*target_classes)[source]

Bases: sqlalchemy.sql.visitors.ReplacingCloningVisitor

remove refs to tombstone_date in an expression

replace(elem)[source]

Receive pre-copied elements during a cloning traversal.

If the method returns a new element, the element is used instead of creating a simple copy of the element. Traversal will halt on the newly returned element if it is re-encountered.

class assembl.lib.history_mixin.HistoricalProxy(target, timestamp, assume_in_time=False)[source]

Bases: object

A proxy for base objects, that will wrap an object and related objects with their version at a given time.

class assembl.lib.history_mixin.HistoryMixin[source]

Bases: assembl.lib.history_mixin.TombstonableMixin

Mixin class for objects with history

It is possible to take a snapshot of objects of this class to have a record of earlier states. The snapshot is invoked explicitly (through copy(True)()), not every time the object is changed. Mainly used for synthesis snapshots.

copy(tombstone=None, db=None, **kwargs)[source]

Clone object, optionally as tombstone (aka snapshot) reuse base_id. Redefine in subclasses to define arguments

property latest

The latest object in this series; may not be live.

property live

The live version of this object, if any.

version_at_time(timestamp)[source]

The object that existed at that time, if any. Note that without a creation date, we may get an object that did not exist.

class assembl.lib.history_mixin.HistoryMixinWithOrigin[source]

Bases: assembl.lib.history_mixin.HistoryMixin, assembl.lib.history_mixin.OriginMixin

classmethod version_at_time_q(base_id, timestamp, db=None)[source]

The object that existed at that time, if any.

class assembl.lib.history_mixin.TombstonableMixin[source]

Bases: object

Mixin class for objects that can be tombstoned

These objects can be killed, leaving a tombstone behind, i.e. an inactive row. TODO: Generate a DB view on live objects.

classmethod base_conditions(alias=None, alias_maker=None)[source]

By default exclude tombstones

class assembl.lib.history_mixin.TombstonableOriginMixin[source]

Bases: assembl.lib.history_mixin.TombstonableMixin, assembl.lib.history_mixin.OriginMixin

assembl.lib.history_mixin.reln_in_history(self, name, timestamp)[source]

read a relation at a given timestamp

monkey-patched as a method of Base in modules.__init__