I have a zsql method to which I want to pass and argument. Normally I do it from a dtml method and the use something like this to test for equality. WHERE description = <dtml-sqlvar description type=string>. However, I'm passing the variable from a python script and it won't accept the dtml tag.... what do I put in the equality test? Kate
You can pass arguments to ZSQL Methods. In this particular case, I assume that you don't want the WHERE clause in the query if the 'description' parameter is not passed? You can do it like this (inside the query): --------------8<------------------------ <dtml-if description> WHERE description = <dtml-sqlvar description type="string"> </dtml-if> --------------8<------------------------ Then, inside your python script: --------------8<------------------------ desc = 'some string' context.path.to.query.queryname(description=desc) --------------8<------------------------ Hope that helps! fm On 11/10/05, Kate Legere <klegere@kfpl.ca> wrote:
I have a zsql method to which I want to pass and argument. Normally I do it from a dtml method and the use something like this to test for equality.
WHERE description = <dtml-sqlvar description type=string>.
However, I'm passing the variable from a python script and it won't accept the dtml tag.... what do I put in the equality test?
Kate
_______________________________________________ Zope maillist - Zope@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 )
That was it exactly - I didn't have the right python syntax but had thought the mistake was in the zsql. Thanks! Kate -----Original Message----- From: zope-bounces@zope.org [mailto:zope-bounces@zope.org] On Behalf Of Floyd May Sent: Thursday, November 10, 2005 12:04 PM To: Zope Subject: Re: [Zope] msSql and python You can pass arguments to ZSQL Methods. In this particular case, I assume that you don't want the WHERE clause in the query if the 'description' parameter is not passed? You can do it like this (inside the query): --------------8<------------------------ <dtml-if description> WHERE description = <dtml-sqlvar description type="string"> </dtml-if> --------------8<------------------------ Then, inside your python script: --------------8<------------------------ desc = 'some string' context.path.to.query.queryname(description=desc) --------------8<------------------------ Hope that helps! fm On 11/10/05, Kate Legere <klegere@kfpl.ca> wrote:
I have a zsql method to which I want to pass and argument. Normally I do it from a dtml method and the use something like this to test for equality.
WHERE description = <dtml-sqlvar description type=string>.
However, I'm passing the variable from a python script and it won't accept the dtml tag.... what do I put in the equality test?
Kate
_______________________________________________ Zope maillist - Zope@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 )
_______________________________________________ Zope maillist - Zope@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 )
Floyd May a écrit :
You can do it like this (inside the query): --------------8<------------------------ <dtml-if description> WHERE description = <dtml-sqlvar description type="string"> </dtml-if> --------------8<------------------------
Or like this: <dtml-sqlgroup where> <dtml-if description> <dtml-sqltest description type=string> </dtml-if> </dtml-sqlgroup> -- Bertrand Croq - FreesKop - Avenue Robert Schuman - 35170 BRUZ http://www.freeskop.com/ - Tel: 02 99 05 04 56 - Fax: 02 99 05 96 40
participants (3)
-
Bertrand Croq -
Floyd May -
Kate Legere