开发者

db.Model class variables and __init__

(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 som开发者_如何学Goe kind of special GAE requirement?


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/init.py

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜