Section on revision control architecture updated.
diff --git a/NewDocumentEditor.wiki b/NewDocumentEditor.wiki index 7d28b9a..0177f54 100644 --- a/NewDocumentEditor.wiki +++ b/NewDocumentEditor.wiki
@@ -6,43 +6,34 @@ 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 architecture = -There are several issues that should be taken into account: - # Loose coupling. Information about revisions must be represented as a separate model to minimize dependencies between document entities and revisions. - # Minimize the size of the data retrieved. - # Minimize datastore queries and simplify them. +Revision control implementation involves creation of three separate models: Revision, !RevisionInfo and !RevisionContent. -== First approach: independent revisions == +The main purposes of Revision are: + # Denote that derived model implements revision control. + # Store list of keys for !RevisionInfo entities. + {{{ -class Revision(db.Model): - revision_id = db.IntegerProperty() - timestamp = db.DateTimeProperty() # It's not required, cause Document entity has it - user = db.UserProperty() # It's not required, cause Document entity has it - comment = db.TextProperty() # Comment about the revision - current = db.BooleanProperty() # Current revision - deleted = db.BooleanProperty() # Revision is marked as deleted - public = db.BooleanProperty() # Public or private revision - document = db.ReferenceProperty() # Reference to content +class Revision(soc.models.base.ModelWithFieldAttributes): + revisions = db.ListProperty(db.Key, verbose_name = ugettext("Revisions")) }}} -It's obvious that revisions are not linked to each other. Each operation on revision is just a query to a datastore. +Revision can be added to the list of base classes of the model, as GAE supports multiple inheritence for models since 1.2.4. -== Second approach: Linked revisions == +!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 DocRevision(db.Model): - revision_id = db.IntegerProperty() # It's necessary for list rearrangement - timestamp = db.DateTimeProperty() # It's not required, cause Document entity has it - user = db.UserProperty() # It's not required, cause Document entity has it - comment = db.TextProperty() # Comment about the revision - document = db.ReferenceProperty() # Reference to content - -class Revision(db.Model): - revisions = db.ListProperty(db.Key) # List of revisions - public = db.ListProperty(db.Key) - private = db.ListProperty(db.Key) +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) }}} -This approach helps to manage revisions easily, but list rearrangement operations consumes expensive CPU time. - +!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")) +}}} + = Project timeline = == Week 1 (24 May - 30 May) == # Dig into GAE datastore (read [http://oreilly.com/catalog/9780596522735 "Programming Google App Engine"], review google.appengine.ext.db, play with the datastore)