[Zope] multiple optional args to zsql method?

Thierry Florac thierry.florac@onf.fr
26 Nov 2002 12:03:36 +0100


  Hi,


On Mon, 2002-11-25 at 20:02, Skip Montanaro wrote:
> I have this ZSQL method:
> 
>     <params>
>     id
>     zope_username
>     </params>
>     select * from worker
>       <dtml-sqlgroup where>
>         <dtml-sqltest name="id" op="eq" type="int" optional>
>       <dtml-or>
>         <dtml-sqltest name="zope_username" op="eq" type="string" optional>
>       </dtml-sqlgroup>
>     ;
> 

I use this kind of syntax without a problem (excepted the fact that I
use "<dtml-sqltest zope_username type=string optional>", so without
double quotes and the 'name' field).
Are you sure that "zope_username" isn't defined anywhere else in your
environment ??


> In addition, if I call it as
> 
>     context.sql.get_worker(zope_username=user.getUserName())
> 
> from a Python script, it complains "Invalid integer value for id".

I had the same problem. I think that if a parameter is missing but
exists into the environment, the SQL template is retrieving the given
value from it. As "id" is always defined, changing the parameter name
from "id" to anything else may solve the problem, using something like :

  <dtml-sqltest newid column=id type=int optional>


Thierry