The goal of the project is to develop and/or deploy new infrastructure for document editing in Melange. This infrastructure should provide revision control of the documents, displaying diffs between revisions, storing documents in HTML and markdown. MarkItUp! can be deployed as an optional editor.
Revision control implementation involves creation of three separate models: Revision, RevisionInfo and RevisionContent.
The main purposes of Revision are:
class Revision(soc.models.base.ModelWithFieldAttributes): revisions = db.ListProperty(db.Key, verbose_name = ugettext("Revisions"))
Revision can be added to the list of base classes of the model, as GAE supports multiple inheritence for models since 1.2.4.
RevisionInfo stores information about the revision. Revision number, author, date and time of creation, etc. All the meta goes here. RevisionInfo also contains reference to RevisionContent entity. Keys for the RevisionInfo entities may be implemented as
"%s_%d" % (entity_key, revnumber). This helps to retrieve given revision without retrieving model entity. Division of info and content is crucial for revision control. Some operations on revisions manipulate only info, but not the content. One can consider view that shows all the revisions for the current entity.
class RevisionInfo(soc.models.base.ModelWithFieldAttributes): revnumber = db.IntegerProperty(required = True) author = db.ReferenceProperty(reference_class = soc.models.user.User, required = True) created = db.DateTimeProperty(auto_now_add = True) content = db.ReferenceProperty(reference_class = RevisionContent, required = True)
RevisionContent stores the content. Content can be stored as plain text, JSON or something else. Revision model may implement methods to store the content in different formats. This methods can be redefined in derived models.
class RevisionContent(soc.models.base.ModelWithFieldAttributes): content = db.TextProperty(verbose_name = ugettext("Content"))