> 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 in some_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