Re: [web2py] Re: Helper for many-to-many result sets?

2012-08-14 Thread Bruno Rocha
Taking this exact example Foreach movie in movies print movie.title foreach stars in movie.stars print star.name I guess `movie.stars` is a list:string field? if so.. there's one-liner solution table = TABLE(*[TR(TD(movie.title), TD(UL(*[LI(star.name) for star in

Re: [web2py] Re: Helper for many-to-many result sets?

2012-08-14 Thread Bruno Rocha
I guess you can also do: table = TABLE(*[TR(TD(movie.title), TD(UL(*[LI(star.name) for star in * movie.stars.select()*])) for movie in movies]) when a table is referenced by another, he gets a DAL Set object with the referer name. movie.*stars *will be a DAL Set. which has *select, update,

Re: [web2py] Re: Helper for many-to-many result sets?

2012-08-14 Thread Mike Girard
Salient bits of model at the top of the thread. On Tuesday, August 14, 2012 2:16:56 AM UTC-4, rochacbruno wrote: I guess you can also do: table = TABLE(*[TR(TD(movie.title), TD(UL(*[LI(star.name) for star in * movie.stars.select()*])) for movie in movies]) when a table is referenced by

Re: [web2py] Re: Helper for many-to-many result sets?

2012-08-14 Thread Mike Girard
This all looks promising. Meanwhile, here's my model with irrelevant Fields omitted and below that my query for the Select. Thanks for the help! A simplified version of my model: db.define_table('movie', Field('title','string'), db.define_table('person', Field('name', 'string',

[web2py] Re: Helper for many-to-many result sets?

2012-08-13 Thread Cliff Kachinske
There may be a more elegant way to do this, but it does work. Be sure to select the movie id in your query. Then you can do something like this: rows = db(query).select(.) #whatever you're doing trows = [] stars = [] for i, r in enumerate rows: stars.extend([r.stars.name, BR()]) if