[Zope] ZSQL Methods: surprising behavior, subtle bug

Shai Berger shai@aristocart.com
Mon, 26 Feb 2001 19:40:50 +0200


Hi,

We just found a very subtle bug in our own application,
which was caused by what I think is a surprising behavior
of ZSQL methods. Actually, it's a feature of the query
results. What we see is that they acquire the environment
in which they were created. Essentially, our code did this

<dtml-in query0>
 <dtml-let result1=query1 result2=query2>
  <dtml-with result1[0]>
   <dtml-with result2[0]>
    <dtml-var returned-by-both-query0-and-query1-but-not-query2>
   </dtml-with>
  </dtml-with>
 </dtml-let>
</dtml-in>

(Of course, the real setting is more complex, e.g. the dtml-withs
are in a separate dtml-method, called within the let)

To our surprise, the dtml-var picks the value of the variable as
returned from query0. This is, I think, because this value is 
acquired by result2 where it is defined. I've checked this
by accessing the variable as an attribute of the query-result row.

Thought you'd all like to know,

Shai.