Reputation: 534
described in http://code.google.com/intl/en/appengine/docs/python/datastore/propertyclass.html#Property
but there is no example code.
i code sth like:
class Model(db.Model):
email = db.EmailProperty(validator=clean_email)
def clean_email(self,value):
if ...
Upvotes: 0
Views: 936
Reputation: 101149
You need to either define the method before the property, as joetsuihk demonstrates, or define it as a function, outside the class. I would recommend the latter, as there's no reason for the validator to be associated with the class.
Upvotes: 1
Reputation: 534
class Model(db.Model):
def clean_email(value):
if ...
email = db.EmailProperty(validator=clean_email)
use a argument. and the argument itself is the value of email in this case.
Upvotes: 2