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

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -