@manuele @Anthony Many thanks for your help with this. As usual with Web2Py 
and gluon there is always an easy way. the .belongs() is perfect for what I 
need.

Simon

On Friday, 24 May 2013 13:37:37 UTC+1, Anthony wrote:
>
>
> buildCommod = "("
>>                 for commodity in commodityList:
>>                     buildCommod += "(db.weekly_data.itemgroup == '" + 
>> commodity + "')|"
>>                 buildCommod = buildCommod[:-1] + ")"
>>
>>  RS_Data = db(
>>                              (db.weekly_data.week == weekno)& buildCommod 
>> &
>>
>
> As you have constructed it, buildCommon is simply a string, not a DAL 
> Query object -- so you have inserted a string in the midst of a query. You 
> could do eval(buildCommon) to evaluate the string into a Query object, but 
> please don't do it that way. If you need to join a number of queries with 
> |, you can do it in a loop using the |= operator, or you can use reduce():
>
> query = reduce(lambda a, b: a | b, [[query goes here] for item insome_list
> ])
>
> If the query is just testing equality, though, it's even easier to use 
> .belongs():
>
> buildCommon = db.weekly_data.itemgroup.belongs(commodityList)
>
> Anthony
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to