[Zope] Problem using dtml-in in ZSQL method

Jaroslav Lukesh lukesh at seznam.cz
Thu Dec 11 10:55:00 EST 2008


first, convert mylist to string before calling ZSQL method:

<dtml-call "REQUEST.set('strmylist', _.str(mylist))">

And then call the ZSQL method:

<params>
strmylist:string="[0]"
</params>

SELECT *
FROM MyTable
WHERE
  id in
    (<dtml-var "strmylist[1:-1]" sql_quote>)


----- Original Message ----- 
From: Françoise CONIL
To: zope at zope.org
Sent: Thursday, December 11, 2008 11:21 AM
Subject: [Zope] Problem using dtml-in in ZSQL method


Hello,

My ZSQL method receive a *mylist* parameter that should be an integer list : 
[21,35]

The following code does not work :

SELECT *
FROM MyTable
WHERE
  id in
    (<dtml-in mylist>
        <dtml-sqlvar sequence-item type=int> <dtml-if 
sequence-last><dtml-else>,</dtml-if>
    </dtml-in>)


*Type de l'erreur*
NameError
*Valeur de l'erreur*
'client' may not be used as an argument name in this context

This other code does not work better :

SELECT *
FROM MyTable
WHERE
  id in
    (<dtml-in mylist prefix="myid">
        <dtml-sqlvar expr="myid_item" type=int> <dtml-if 
sequence-last><dtml-else>,</dtml-if>
    </dtml-in>)

*Same error*

However, if I use a dictionary list of this type [{'id':21},{'id':35}]  with 
the following code, it works (but it's heavy)

SELECT *
FROM MyTable
WHERE
  id in
    (<dtml-in mylist mapping>
        <dtml-sqlvar id type=int> <dtml-if 
sequence-last><dtml-else>,</dtml-if>
    </dtml-in>)

The python script that calls my ZSQL method has already build the integer 
list and I would like to use it as is.

Thanks for your help




_______________________________________________
Zope maillist  -  Zope at zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists -
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev ) 



More information about the Zope mailing list