I have an object that can contain references to other objects of the same type. In my validator I want to ensure the references are not to itself. Is this possible to do?
class MyObject(db.Model):
def not_self_validator(value):
if self._my_entity == value: #something like this..
logging.warn('attempted to set object to itself')
raise ValueError('Unable to set an object to itself')
_my_entity = db.ReferenceProperty(db._SELF_REFERENCE,required=False,default=None,validator=not_self_validator)
The property validator can receive any method/function, but it is not possible to bond that method to self. However you can adapt your validation routine to something like this: