Hi Hassan --
In web2py, the Field object is a subclass of Expression. That's how you
can use it with comparison symbols. When you pass it to the database
connection as a function, it produces a Set which loosely represents the
rows of the database that will eventually be "selected" (but the select has
not happened at this stage). One cool feature is that Sets can be refined
by adding more Expressions.
It sounds like what you are trying to do is something like this:
set1=db((db.table.field1=='value1')&(db.table.field2=='value2))
And later, refine the set further:
set2=*set1*(db.table.field3=='value3')
In this case, set2 is a refinement of set1. It's the same set as if you
combined the definitions:
set2=db((db.table.field1=='value1')&(db.table.field2=='value2')&(db.table.
field3=='value3'))
One more point -- your "request.args(1)" should be "request.args[1]" (with
square brackets). The first form calls request.args as a function and
passes it the value "1". The second form treats request.args as a Storage
object and asks for the subscript "1".
-- Joe Barnhart
On Tuesday, November 6, 2012 9:33:09 AM UTC-8, Hassan Alnatour wrote:
>
> Dear ALL ,
>
> i am trying to do this :
>
> sup = db(
> (db.Supplements.Category == (request.args(1)).replace('_',' ')) & (db.
> Supplements.Users == str(request.args(0)) or 'Both')
> ).select(db.Supplements.ALL)
>
> But its not working , any help ???
>
> REgards,
>
--