I'm making a spam filter library for google app engine, which uses app engine hooks to modify some data right before it is put()
into the datastore. To do so, I created a model that subclasses the PolyModel class, which classes wishing to be checkable should subclass.
But for some data in the class, I'd like to do some stuff when the value is changed, for which I'd have to overwrite __setitem__
. But I believe the sdk uses this to determine changes in the properties of models, apply filters etc, and so changing overwriting __setitem__
might break this. What's the best way around this?
There is no danger in overriding methods, if you don't forget to call the parent method with super
. But in your case __setitem__
is wrong place, because then everytime when instance is created it will be cleaned from spam, even if it is created from already cleaned values.
What is wrong if you do that explicitly?
filter_out_spam(obj)
obj.put()