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.

Reply via email to