Be aware that in current version save() contains code literally copied
from put() so you'd like to have in your model class the code like:

def put(self):
  # do something before save
  key = super(MyModel, self).put()
  # do something after save
  return key

save = put

On 13 Mar, 05:45, yucc <yucc2...@gmail.com> wrote:
> Hi all,
> I want to overwrite the default save method of the
> google.appengine.ext.db.Model so as to perform some special work each
> time the entity save(or update),I know in Django model this should be
> like this:(in the model definition)
> def save(self, force_insert=False, force_update=False):
>         self.level = self.level+1   #I want to let the level property
> auto add
>         super(User, self).save(force_insert, force_update) # Call the
> "real" save() method.
>         #do_something_else()
>
> But, this doesn't work with google.appengine.ext.db.Model,it comes out
> that the Model's put method takes  exactly 1 argument,so I omit
> them,like this:
> super(User, self).save(),
> Is that right?
> I was wondering how to construct a Model,as there's a init method:
> def __init__(self, parent=None, key_name=None, _app=None,
> _from_entity=False, **kwds)
> It seems "super(User, self)" is not right here
> Anyone could help ?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to