python - Add functions to models in Google App Engine DataStore -
i using google app engine python , datastore. possible define model, , attach functions directly model?
class servicestate(db.model): service = db.stringproperty(required=true, choices=('api', 'db')) current = db.stringproperty(required=true, choices=('up', 'down')) def change(self, new_state): # other logic here self.current = new_state; self.put()
then like:
ss = models.servicestatus.gql("where service = :1", "api") ss.change("down")
update
tried , getting:
attributeerror: 'gqlquery' object has no attribute 'change'
Comments
Post a Comment