About represent_dict[...], I use to construct dict of id (key) / represent (value) for some table where the represent if formed from the concatation of attribute from differents tables. So instead of having to query 2 tables I just call my dict... Of course, I have to update once in a wild the dict, but since that these values are read more often than they update, it is not a big deal.
Richard On Wed, Aug 14, 2013 at 8:31 AM, Richard Vézina <[email protected] > wrote: > Great!! > > Thank you Anthony for clarification. That exactly what I was needing. > > I should have read more carefully validators section I guess. > > :) > > Richard > > > On Tue, Aug 13, 2013 at 6:03 PM, Anthony <[email protected]> wrote: > >> >> I have table a that is referenced by table b, so there is a_id FK field >>> in table b. But now I want table c to reference table b but to discriminate >>> record I need the representation of a id in the dropbox of c form because b >>> table are meaning less with a id represent. >>> >>> It occurs that IS_IN_DB does not let you access the value of the >>> referenced table, I mean I can't do something like this : >>> >>> IS_IN_DB(db, 'b.id', represent_dict[a_id] + b.other_field) >>> >> >> The third argument to IS_IN_DB can be a callable that takes the row >> object from the select, so it can generate whatever representation you >> want. I'm not sure what you mean by represent_dict[a_id], but perhaps >> something like: >> >> IS_IN_DB(db, 'b.id', lambda r: db.table_a(r.a_id).some_field + r. >> other_field) >> >> If the representation is more complex, you can define a separate function >> rather than using a lambda. >> >> Also, note that IS_IN_SET can take a dictionary or list of tuples -- see >> the book section on it. >> >> Anthony >> >> -- >> >> --- >> 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/groups/opt_out. >> >> >> > > -- --- 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/groups/opt_out.

