aschmid00
aschmid00

Reputation: 7158

polymodel.PolyModel put() overriding

i need to override the put method on my model because i need to do some special stuff while storing the entity.

the code looks something like this:

class Asset(polymodel.PolyModel):
....

def put(self, rpc=None):
  # do something special
  return self


class Image(Asset):
...

now my problem is that if i call Asset.put() it calls the custom put method while Image.put() uses the default one. If Asset would be a db.Model this works as expected Image.put() would use the custom put().

how can i make the subclass use the custom function? thx

Upvotes: 0

Views: 93

Answers (1)

Adam Crossland
Adam Crossland

Reputation: 14213

While it is possible to monkey-patch your classes to allow you to change the behavior of put(), you might be better off writing a method -- call it save() for the sake of argument -- that wraps the put() in a more explicit and obvious fashion and frees you from having to worry about having the patched behaviors being inherited or not by subclasses.

Upvotes: 2

Related Questions