Yeah, that doesn't help me understand it very well -- could probably use some treatment in the book.
On Sep 21, 7:16 pm, Jose Hurtado <[email protected]> wrote: > A quick search gives me only 1 result, on chapter six, on section: > > "Many to Many, list:<type>, and contains" > > used as a value on a validator. > > but could be useful for more people to know. > > cheers. > > On 22 sep, 00:02, Anthony <[email protected]> wrote: > > > > > Is this in the book anywhere (i.e., _format)? > > > Thanks. > > > On Sep 21, 5:09 pm, mdipierro <[email protected]> wrote: > > > > You can do > > > > db.define_table('person',Field('name')) > > > > db.define_table('dog',Field('name')) > > > format=lambda r: r.name+' belongs to '+r.person.name) > > > > and > > > > for dog in db(db.dog.id>0).select(): > > > print db.dog._format(dog) > > > > On Sep 21, 3:29 pm, Jose Hurtado <[email protected]> wrote: > > > > > i now have the lambda function defined, but... on the view, how call i > > > > the function format, the record is stored under 'row' key on > > > > dictionary passed to the view. i tried row.format, row.represent,... > > > > but i only get errors :( > > > > > one thing, my query access the record by the id, not by the reference > > > > field under another table. > > > > > On 21 sep, 21:52, mdipierro <[email protected]> wrote: > > > > > > format can be a function > > > > > > db.define_table('person',Field('first_name'),Field('last_name'), > > > > > format=lambda r: r.first_name+' '+r.last_name) > > > > > > where r is the record to be represented. Hope that helps. > > > > > > On Sep 21, 10:51 am, Jose Hurtado <[email protected]> wrote: > > > > > > > Hello, > > > > > > > just started using web2py a few days ago and liked it so here i am > > > > > > with my first app :) > > > > > > > so sorry if my question have been solved, i did a few searches a > > > > > > didn't find it. > > > > > > > My problem: > > > > > > > I want to get a string representation of a record of a table, this > > > > > > representation can be as easy as 1 field, or could be several fields > > > > > > formatted. > > > > > > > In the db.define_table function, i included the format parameter > > > > > > setting the representation i want for the record, but i think i can > > > > > > only use it for select/option drop-downs and in reference fields on > > > > > > another table. Another way could be to define a virtual field with > > > > > > the > > > > > > format i want, so i can write row.personalized_virtual_field to get > > > > > > the string representation, and use format='% > > > > > > (personalized_virtual_field)s' to avoid repeating code (the > > > > > > definition > > > > > > of the format). > > > > > > > Is this the way to do? or am i a bit lost and it could be done an > > > > > > easy > > > > > > way? > > > > > > > Thank you.- Hide quoted text - > > > > - Show quoted text -- Hide quoted text - > > - Show quoted text -

