Revisioned content ================== .. automodule:: nodular.revisioned :members: .. class:: nodular.revisioned.RevisionedNodeMixin.RevisionMixin The RevisionMixin base class is available from subclasses of :class:`RevisionedNodeMixin`. It describes the model for a revision of the :class:`RevisionedNodeMixin` node and defines relationships between the two models. For usage instructions, see :class:`RevisionedNodeMixin`. RevisionMixin adds the following attributes and methods to your class. .. attribute:: __parent_model__ Refers to the parent :class:`RevisionedNodeMixin` subclass for which this model stores content revisions. .. attribute:: __tablename__ Autogenerated table name (parent table name with ``'_revision'`` suffixed). .. attribute:: node_id .. attribute:: node Id and relationship to the parent model instance. The foreign key constraint refers to the parent model and *not* to the :class:`~nodular.node.Node` table to ensure that a revision cannot be accidentally attached to the wrong type of node. .. attribute:: status Unique workflow status code for this node, ``None`` for archived revisions. A given revision code may be used by only one revision in a document, to indicate a revision currently flagged as Draft, Pending or Published. .. attribute:: user_id .. attribute:: user The user who created this revision. In a multi-user editing environment, only one user can be tagged as the creator of the revision. .. attribute:: previous_id .. attribute:: previous Id and relationship to previous revision that revision revises. .. method:: copy() Copies this revision into a new revision attached to the same parent model. :meth:`copy()` is not content aware; your subclass will need to override :meth:`copy` to copy contents:: class MyDocumentRevision(MyDocument.RevisionMixin, db.Model): content = db.Column(db.UnicodeText) def copy(self): revision = super(MyDocumentRevision, self).copy() revision.content = self.content return revision