db(db.person.id==db.cats.owner).select(db.cats.ALL, db.person.ALL,
orderby=db.cats.id)

is a join. GAE cannot do join and you cannot sort by ID. You can do

cats = db().select(db.cats.ALL)
for cat in cats: print cat.name, cat.owner.name

or many times faster:

cats = db().select(db.cats.ALL)
person_map = db().select(db.cats.ALL,cache=(cache.ram,
60)).as_dict(storage_to_dict=False)
for cat in cats: print cat.name, person_map[cat.owner].name




On Apr 6, 1:50 am, kedai <[email protected]> wrote:
> On Apr 5, 11:40 pm, Ross Peoples <[email protected]> wrote:
>
> > You should really be joining the queries:
>
> > records = db(db.person.id==db.cats.owner).select(db.cats.ALL, db.person.ALL)
>
> > Then in your view, you access this by using:
>
> > {{for record in records:}}
> >     <b>{{=record.person.name}}</b>: {{=record.cats.name}}
> > {{pass}}
>
> Thanks for the info.  Works great for web2py.  However not that great
> if I deployed to gae.
>
> Got this traceback:
> ERROR    2011-04-06 06:43:17,658 restricted.py:55] In FILE: /home/kdie/
> projek/web2py/applications/init/controllers/my.py
>
> Traceback (most recent call last):
>   File "/home/kdie/projek/web2py/gluon/restricted.py", line 188, in
> restricted
>     exec ccode in environment
>   File "/home/kdie/projek/web2py/applications/init/controllers/
> my.py:e2011", line 72, in <module>
>   File "/home/kdie/projek/web2py/gluon/globals.py", line 124, in
> <lambda>
>     self._caller = lambda f: f()
>   File "/home/kdie/projek/web2py/gluon/tools.py", line 2331, in f
>     return action(*a, **b)
>   File "/home/kdie/projek/web2py/applications/init/controllers/
> my.py:e2011", line 14, in e2011
>   File "/home/kdie/projek/web2py/gluon/dal.py", line 5097, in select
>     return self.db._adapter.select(self.query,fields,attributes)
>   File "/home/kdie/projek/web2py/gluon/dal.py", line 2977, in select
>     (items, tablename, fields) =
> self.select_raw(query,fields,attributes)
>   File "/home/kdie/projek/web2py/gluon/dal.py", line 2926, in
> select_raw
>     tablename = self.get_table(query)
>   File "/home/kdie/projek/web2py/gluon/dal.py", line 962, in get_table
>     raise RuntimeError, "Too many tables selected"
> RuntimeError: Too many tables selected
>
> line 14 refers to records =
> db(db.person.id==db.cats.owner).select(db.cats.ALL, db.person.ALL,
> orderby=db.cats.id)

Reply via email to