Maybe this thread could be of some help.

http://groups.google.com/group/web2py/browse_thread/thread/e533b38bd5bf1d7f#

<http://groups.google.com/group/web2py/browse_thread/thread/e533b38bd5bf1d7f#>



On Thu, Oct 21, 2010 at 2:05 PM, BigBaaadBob <bigbaaad...@gmail.com> wrote:

> Suppose you do a query like this:
>
> rows = db((db.a.id==db.foo.xx) &
> (db.b.id==db.foo.yy)).select(db.foo.id, db.foo.aaa, db.a.name,
> db.b.name, db.foo.zzz, ....)
>
> And you want to processes the results generically, say to produce JSON
> for input to jqGrid.  By generically, I mean not having to repeat the
> "db.foo.aaa, db.a.name" stuff.  You know, DRY.
>
> For r in rows:
>   stuff...
>
> What is the supported way of doing this?
>
> Problems I see are:
>
>   * You can't say: r[0] because row is a dict with keys 'a', 'b', and
> 'foo'.
>   * You can't say: r[rows.colnames[0]] because, well, the same reason
> as the previous item.
>
> I see code in the Rows class like this:
>
>           (t, f) = col.split('.')
>                 if isinstance(record.get(t, None), (Row,dict)):
>                        row.append(none_exception(record[t][f]))
>
> But I wouldn't want to do that because it assumes the internal
> structure of the Rows class...
>
>

Reply via email to