views:

72

answers:

2

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 ...
A: 
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.

joetsuihk
A: 

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.

Nick Johnson