Hi all, once again I turn to you with my latest question.
I have a self-referencing table:
db.define_table('accounts',
Field('name','string'),
Field('parent_account','reference accounts'),
Field('account_type','string'))
What I'm trying to achieve is to create a tree-like structure. So we have 5
"root" accounts, which can each hold some sub-accounts etc.
Now the account_type must be the same for all the children of a certain
account. So the root accounts pre-determine all of the children's account
type, rendering it unwritable for a child account.
For some reason the following didn't work for me:
account_types = ['a','b','c']
db.accounts.account_type.requires = IS_IN_SET(account_types)
db.accounts.account_type.required = True
db.accounts.account_type.compute = lambda x:
x['parent_account'].account_type
db.accounts.account_type.writeable = lambda x: (x['parent_account'] == 0)
Thanks for your help,
Tsvi