Interactively trying gae code

import sys
sys.path.append(‘c:/program files (x86)/google/google_appengine’)
sys.path.append(‘c:/Program Files (x86)/Google/google_appengine/lib/yaml/lib’)
from google.appengine.ext import db
import datetime

class A(db.Model):
date = db.DateProperty()

class B():
date = datetime.date.today()

a = A(date=datetime.date.today())
print a.date.month
b = B()
print b.date.month

prints:
>>10
>>10

the db.Model class does some magic to ensure that the date argument passed to ctor of A is of type datetime.date

Note that a.date is of type datetime.date. It is NOT a DateProperty.

>>> a.date
datetime.date(2011, 10, 2)
>>> b.date
datetime.date(2011, 10, 2)
This entry was posted in Software. Bookmark the permalink.

Leave a comment