views:

41

answers:

1

(New to Python and GAE)

I'm looking for an explanation to the use of class variables in db.Model subclasses, which are treated like instance variables. Why are these declared in class scope and not in __init__? Is this some kind of special GAE requirement?

+3  A: 

Yes, this is a programming model special to GAE. You can think of the class properties as the table definition. The instance properties are the contents of a row, they are populated on the fly by the metclass db.PropertiedClass.

There is a lot going on under the hood, if you are interested always have a look at the source: http://code.google.com/p/googleappengine/source/browse/trunk/python/google/appengine/ext/db/%5F%5Finit%5F%5F.py

Daniel Hepper
It is very similar to the way that Django's database models work.
codeape