Hey,
I'm trying to validate some things on a self reference field, among them
that a reference field on a table does not refer to the record where it is.
For instance,
db.define_table('person',
Field('name', length=256, unique=True, requires=IS_NOT_EMPTY()),
Field('gender', requires= IS_IN_SET([T('Male'), T('Female')],
zero=T('choose one'))),
Field('father', 'reference person'),
Field('mother', 'reference person'),
format = '%(name)s'
)
db.person.father.requires = IS_EMPTY_OR(IS_IN_DB(db(db.person.gender ==
'Male'), db.person.id, '%(name)s', zero=T('choose one')))
db.person.mother.requires = IS_EMPTY_OR(IS_IN_DB(db(db.person.gender ==
'Female'), db.person.id, '%(name)s', zero=T('choose one')))
So in addition to the gender restriction (yeah I know it's not always true,
this is just an example), I'd like to add the restriction that a person
cannot be it's own father or mother.
Basically what I want is something like an IS_NOT_SELF or something.
Any tips on how to go about this?