Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 718e9cc100
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

executable file 35 lines (28 sloc) 1.237 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
from revisions import models

class VersionedModelShortcuts(object):
    """
VersionedModel defines a few common operations (check_if_latest_revision,
get_latest_revision) that involve a database lookup. Common practice dictates that
these should be implemented as methods rather than as properties, because properties
would signal to the programmer that a simple lookup is taking place.
However, because we value code that feels as natural and domain-driven as possible,
and because the database lookups involved are fairly quick queries, we've also included
a helper class that implements these common operations as properties -- a few convenient
shortcuts if you will.
"""
    @property
    def revisions(self):
        return self.get_revisions()

    @property
    def is_latest_revision(self):
        return self.check_if_latest_revision()
    
    @property
    def latest_revision(self):
        return self.get_latest_revision()

class VersionedModel(models.VersionedModel, VersionedModelShortcuts):
    class Meta:
        abstract = True

TrashableModel = models.TrashableModel

class TrashableVersionedModel(VersionedModel, TrashableModel):
    class Meta:
        abstract = True
Something went wrong with that request. Please try again.