Databases Reference
In-Depth Information
The next few sections get deeper into data modeling and create, read, update, and delete (CRUD)
operations for application data in the GAE data store. For the purposes of context and specifi city,
concepts are explained via a sample application instead of abstract ideas.
Task Manager: A Sample Application
Consider a simple task management application in which a user can defi ne a task, track its status,
and check it as done once completed. To defi ne a task, the user needs to give it a name and a
description. Tags can be added to categorize it and start, and expected due dates could be specifi ed.
Once completed, the end date can be recorded. Tasks belong to a user and in the fi rst version of the
application they are not shared with anyone other than the owner.
To model a task, it would be helpful to list the properties, specify the data type for each property,
state whether it's required or optional, and mention whether it is single or multiple valued.
Table 10-1 lists a task's properties and its characteristics.
TABLE 10-1: Properties of a Task
PROPERTY NAME
DATA TYPE
REQUIRED
SINGLE OR MULTIPLE VALUED
Name
String
Yes
Single
Description
String
No
Single
start_date
Date
Yes
Single
due_date
Date
No
Single
end_date
Date
No
Single
Tags
array (list collection)
No
Multiple
The GAE Python SDK provides a data modeling API that enables a developer to create a Python
class to represent a task. The simplest form of such a model class for tasks can be as follows:
import datetime
from google.appengine.ext import db
Available for
download on
Wrox.com
class Task(db.Model):
name = db.StringProperty()
description = db.StringProperty()
start_date = db.DateProperty()
due_date = db.DateProperty()
end_date = db.DateProperty()
tags = db.StringListProperty()
taskmanager GAE project
Search WWH ::




Custom Search