Make Donations

Recent site activity

Tutorials‎ > ‎

Create a Simple Guestbook Application using Scaffold

Create project

If your project doesn't exist yet, just create it by gaeo.py

# gaeo.py demo

Create controller, model, and template by scaffold

A guestbook usually has author and content fields, and provide some actions such as add, edit, delete, show, list, and search.
Use scaffold can easily create all files and code needed by a guest, all in one command.
(Notice: some statements have to be quoted because the parentheses is meaningful in bash.)

# gaeogen.py scaffold guestbook new edit show search destroy "username:StringProperty(required=True)" content:TextProperty

This command is like

# gaeogen.py controller guestbook new edit show search destroy
# gaeogen.py model guestbook "username:StringProperty(required=True)" "content:TextProperty()"

but scaffold will also generate related code for you.
For example:

class GuestbookController(BaseController):
    def create(self):
        r = Guestbook(
            username = self.params.get('username', 'Anonymous'),
            content = self.params.get('content', ''),
        )
        r.put()
        self.redirect('/guestbook')

and

from google.appengine.ext import db
from gaeo.model import BaseModel, SearchableBaseModel

class Guestbook(SearchableBaseModel):
    username = db.StringProperty(required=True)
    content = db.TextProperty()

Now, you have a guestbook with simple functions on http://your-app/guestbook/.