python - Storing wiki revisions on Google App Engine/Django - Modifying This Existing Code -


In the past, I have created a Django wiki, and it is quite straightforward to create a page table for the current wiki entries, And then to store the old revision in a revision table.

Recently, I decided to set up a website on Google App Engine, and I used some wiki codes that another programmer wrote. Because he has created his page model in a complex manner (at least for me, complicated) using antiques, I am unsure about how to create an amorphous table and integrate it with its page model.

Does the relevant code have helped me write modification models, and can help save modifications with the method of saving the page model?

  class page (object): def __init __ (self, name, entity = none): Self.name = name self.entity = entity if entity: self.content = entity [' Content '] if entity.has_key (' user '): self.user = entity [' user '] else: self.user = none. Self created Unit ['created'] self Modified = unit ['Modified'] Other: # New pages should start with a simple title to go to the user = datetime.datetime.now () self.content = '& lt; H1 & gt; ' + Cgi.escape (name) + '& lt; / H1> Self.user = none self.created = now self.modified = now def save (self): "" "Creates or edits this page in the datastore." "" Now = datetime.datetime.now () if self.entity: unit = 'self'. Unit: ['name'] = self.name unit ['created'] = now unit ['content'] = datastore_type Text (self.content) unit ['modified'] = now if users.GetCurrentUser (): unit ['user'] = users.GetCurrentUser () elif entity.has_key ('user'): Dell unit ['user'] Datastore.Put (Unit)  

By the way, this code comes in this way:

I am very inexperienced with the GAE Django model, and I am very simple. For example, here is my model for a blog article:

  class article (db.Model): Author = db.UserProperty () Title = db.StringProperty (required = true) Text = DB TextProperty (required = true) tag = db.StringProperty (required = true) date_created = db.DateProperty (auto_now_add = true)  

The code of your first snippet is not a model - it's a custom class that uses a low-level datastore module. If you want to expand it, then I recommend moving it with real models with your model, along with lines similar to the paragraph model shown in your second snippet.

In addition, they are App Engine models, not Django models - Jaguo models do not work on App Engine.


Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -