How would you know whether the field stores an id of the melon table or the 
watermelon table?

On Friday, May 23, 2014 4:52:58 PM UTC-4, Louis Amon wrote:
>
> Due to external constraints, I need to define two tables that are actually 
> siblings and a third table's field that can choose from any of said tables.
>
> e.g.:
> db.define_table('melon')
> db.define_table('watermelon')
>
> I need the third table's field to be a reference to either of the two 
> first tables.
>
> Is there a way to define this in terms of field type and validators ?
> I was thinking along the lines of:
>
> db.define_table('my_table', Field('fruit_id', type=???, 
> requires=IS_IN_DB(db, db.melon, _or=IS_IN_DB(db, db.watermelon)))
>
> or maybe:
>
> db.define_table('my_table', Field('fruit_id', type=???, 
> requires=any([IS_IN_DB(db, db.melon), IS_IN_DB(db, db.watermelon)]))
>
> But of course it doesn't work...
>
>
> How can I work around this issue ?
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to