Ah ok, that makes sense. Is it really that easy to come up with a web request that takes more than thirty seconds? I'll have to watch out for that...
I'm thinking now that I'm going about this the wrong way as regards the design for the datastore - from what I've read, "contains" is an efficient way to query based on a list:reference field, so I'm considering having a field on the course model for people, so I can say something like courses = db(db.course.people.contains(person.id)).select() This would make it more complicated in the controller when I'm updating and inserting rows, but the queries would be efficient. As far as sorting goes, if there is a risk of the request timing out I could even do it in the browser (using a YUI datatable or something to display the data). Thank you for your help! On Aug 20, 8:15 pm, howesc <how...@umich.edu> wrote: > right, so when i need to do a belongs query for more than 30 items: > > items=db(db.my_table.end_user.belongs(id_list[0:30])).select() > for i in range(30, len(id_list)+30, 30): > items = items & \ > db(db.my_table.end_user.belongs(id_list[i-30:i])).select() > > i'd say that web2py should just do that for you, but on GAE you want to be > aware that this is happening because it can easily eat up all 30 seconds > that you have to service a web request, so i like that i have to do it > explicitly (i only try to do queries like this in taskqueue tasks where i > know i can process more data per request) > > for one to many relationship you can use the list:reference property that > maps to the GAE list property. then when you get a row you have a property > that has all the IDs of the records that 'belong' to it, and you can query > for them (perhaps using the above if there is more than 30 in the list) > > hope that helps a little! > > christian > > while it takes more queries, there is nothing stopping you from: > > item_refs = db(db.join_table.sidea=ref_a).select() > items = db(db.sideb_table.id.belongs(item_refs.as_dict().keys()).select() > > it feels yucky by comparison to SQL but it works. i do try and avoid it > because it is inefficient.