> > I have two db tables: > > board (name, created_on) > article(board, name, title) > > currently, in my html I do a naive loop {{for article in articles}} {{= > article.board.name}} {{pass}} > > I would like to change it and do something like: > articles = db.select.all....... > board_ids = set(map(lambda a: a.board_id, articles)) >
Instead of a.board_id, do you mean a.board (I don't see a "board_id" field listed in your article table definition)? Also, is db.article.board a reference field to the db.board table? In that case, that means it is already storing the id of the referenced record in the db.board table (that's what reference fields store), so you don't need to retrieve it separately. Anyway, if you need the db.board.name value for all the records you are selecting from the db.article table, you should probably just do a join so you can get everything in a single query -- see http://web2py.com/books/default/chapter/29/6#Inner-joins. Anthony