开发者

Google App Engine - Adding Methods to subclasses of db.model

I would like to know if I can add methods to a subclass of db.model. For example:

class Session(db.model):
    sessionId = db.StringProperty()
    # More Properties

    def refreshSession(self):
        #do some work
        self.put()

Implementat开发者_高级运维ion:

s = Session()
s.refreshSession()

Is this recommended?


This is the typical way to add behavior to model objects. Why wouldn't you do it this way?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜