Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 416527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T18:29:21+00:00 2026-05-12T18:29:21+00:00

In the past, I created a Django wiki, and it was fairly straightforward to

  • 0

In the past, I created a Django wiki, and it was fairly straightforward to make a Page table for the current wiki entries, and then to store old revisions into a Revision table.

More recently, I decided to set up a website on Google App Engine, and I used some wiki code that another programmer wrote. Because he created his Page model in sort of a complicated way (complicated to me at least) using Entities, I am unsure about how to create the Revision table and integrate it with his Page model.

Here is the relevant code. Could someone help me write the Revision model, and integrate saving the revisions with the Save method of 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 = entity['created']
      self.modified = entity['modified']
    else:
      # New pages should start out with a simple title to get the user going
      now = datetime.datetime.now()
      self.content = '<h1>' + cgi.escape(name) + '</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:
      entity = self.entity
    else:
      entity = datastore.Entity('Page')
      entity['name'] = self.name
      entity['created'] = now
    entity['content'] = datastore_types.Text(self.content)
    entity['modified'] = now

    if users.GetCurrentUser():
      entity['user'] = users.GetCurrentUser()
    elif entity.has_key('user'):
      del entity['user']

    datastore.Put(entity)

By the way, this code comes from: http://code.google.com/p/google-app-engine-samples/downloads/list

I’m pretty inexperienced with GAE Django models, and mine tend to be very simple. For example, here’s my model for a blog Article:

class Article(db.Model):
  author = db.UserProperty()
  title = db.StringProperty(required=True)
  text = db.TextProperty(required=True)
  tags = db.StringProperty(required=True)
  date_created = db.DateProperty(auto_now_add=True)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T18:29:22+00:00Added an answer on May 12, 2026 at 6:29 pm

    I created this model (which mimics the Page class):

    class Revision (db.Model):
      name = db.StringProperty(required=True)
      created = db.DateTimeProperty(required=True)
      modified = db.DateTimeProperty(auto_now_add=True)
      content = db.TextProperty(required=True)
      user = db.UserProperty()
    

    In the Save() method of the Page class, I added this code to save a Revision, before I updated the fields with the new data:

    r = Revision(name = self.name,
                 content = self.content,
                 created = self.created,
                 modified = self.modified,
                 user = self.user)
    r.put()
    

    I have the wiki set up now to accept a GET parameter to specify which revision you want to see or edit. When the user wants a revision, I fetch the Page from the database, and replace the Page’s Content with the Revision’s Content:

    page = models.Page.load(title)
    
    if request.GET.get('rev'):
      query = db.Query(models.Revision)
      query.filter('name =', title).order('created')
      rev = request.GET.get('rev')
      rev_page = query.fetch(1, int(rev))
      page.content = rev_page.content
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created one web application so i want to store my past logged user
In the past, I created my stores using Ext.create('Ext.data.Store', ... and when I wanted
I've created a lot of PHP projects in the past based on quick 'make
i am trying to mark date if the data created in the past 3
In the past I've been able to modify the CSS on a page via
I've been using rails, merb, django and asp.net mvc applications in the past. What
I've created controllers in the past successfully, but all of a sudden I'm getting
My app formerly created useful crash logs. I synced my iPhone in the past
In the past whilst working with AJAX-submitted forms, I have always created the forms
In the past I had successfully created several Google Earth tours complete with audio

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.