[Zope] Dynamic ZSQL method - almost there

Kashif Jabbar kjabbar at ssidecisions.com
Thu Jan 29 23:28:20 EST 2004


Hello,

I have been trying to get the dynamic ZSQL method working for a long 
time and I think I am almost there. Here is what I am doing:

My ZSQL method is named 'mysql' with one argument named 'params':

select * from address where
<dtml-in "params.keys()">
   <dtml-var sequence-item> <dtml-var 
"params[_['sequence-item']]['op']"> '<dtml-var 
"params[_['sequence-item']]['val']">'
   <dtml-unless sequence-end> and </dtml-unless>
</dtml-in>

I am accessing it from a script named 'testsql':

for row in context.mysql(params={'name':{'op':'=','val':'John Doe'}}):
   print row
return printed

When I run the script I get a message as follows:

<r instance at 015C5760>

That is all the message says. Now if I modify the script a little by 
removing the argument and changing it to:

select * from address where
<dtml-let params="{'name':{'op':'=','val':'John Doe'}}">
   <dtml-in "params.keys()">
     <dtml-var sequence-item> <dtml-var 
"params[_['sequence-item']]['op']"> '<dtml-var 
"params[_['sequence-item']]['val']">'
     <dtml-unless sequence-end> and </dtml-unless>
   </dtml-in>
</dtml-let>

I get the desired sql:

select * from address where
       name = 'John Doe'

Can anyone please help me here? I am a newbie and dealing with Zope. It 
has taken a lot of persistence to get to this point. I can't give up 
now.  Thanks in advance.

Kashif





More information about the Zope mailing list