在http://code.google.com/intl/en/appengine/docs/python/datastore/propertyclass.html#Property
中描述但没有示例代码。
我喜欢代码:class Model(db.Model):
email = db.EmailProperty(validator=clean_email)
def clean_email(self,value):
if ...
答案 0 :(得分:2)
class Model(db.Model):
def clean_email(value):
if ...
email = db.EmailProperty(validator=clean_email)
使用参数。在这种情况下,参数本身就是电子邮件的价值。
答案 1 :(得分:1)
您需要在属性之前定义方法,如joetsuihk演示,或者在类外定义它作为函数。我推荐后者,因为没有理由将验证器与班级联系起来。