Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class PropertyFoo(db.StringProperty):
- def validate(self, value):
- # Yes this is a pointless validator, but please read on
- return value
- def get_value_for_datastore(self, model_instance):
- return super(PropertyFoo, self).get_value_for_datastore(model_instance)
- def make_value_from_datastore(self, value):
- return super(PropertyFoo, self).make_value_from_datastore(value)
- class ModelFoo(db.Model):
- foo = PropertyFoo(required=True)
- >>> m = ModelFoo()
- # No errors :(
- >>> m.foo
- # No errors still
- >>> print m.foo
- 'None' # <-- Why???
- BadValueError: Property foo is required
- class PropertyFoo(db.StringProperty):
- def validate(self, value):
- super(PropertyFoo, self).validate(value) #Base implementation checks
- #Do your other check here raising BadValueError
- return value
Add Comment
Please, Sign In to add comment