开发者

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

开发者 https://www.devze.com 2023-03-25 01:59 出处:网络
I would like to know if I can add methods to a subclass of db.model. For example: class Session(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

精彩评论

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