I create a custom db.Property subclass:
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)
Now I also create a db.Model subclass:
class ModelFoo(db.Model):
foo = PropertyFoo(required=True)
So I test them out:
>>> m = ModelFoo()
# No errors :(
>>> m.foo
# No errors still
>>> print m.foo
'None' # <-- Why???
I should expect an error like:
BadValueError: Property foo is required
How do I make sure that my custom Property subclass, when it is required, raises a BadValueError? Am I missing something in my PropertyFoo definition?
I believe you need to call the
validatemethod of the super class: