[Zope-DB] ZSQL picks parameters when it shouldn't
Igor Elbert
ielbert@genuone.com
Thu, 8 May 2003 19:08:57 -0400
I came across a strange situation when ZSQL picks parameters when (it seems
to me) it shouldn't.
Summary: If inner_zsql is called inside <dtml-in outer_zsql> the names
returned by outer_zsql become available to inner_zsql even when not passed
as parameters.
To illustrate it let's say we have a ZSQL:
-------- inner_zsql -----------------------
<params>
P
P2
</params>
See if P is defined [<dtml-sqltest P type="nb" optional>]
-------- end of inner_zsql ----------------
It doesn't matter that it's not a valid SQL - we want to see if it picks a
variable P.
Now, <dtml-let P="1"><dtml-var "inner_zsql(P2=2, src__=1)"></dtml-let>
renders: "See if P is defined []"
Which is what expected.
However: <dtml-in outer_zsql><dtml-var "inner_zsql(P2=2,
src__=1)"></dtml-in>
renders: "See if P is defined [P = '1']"
if outer_zsql defines P variable, for example, as:
-------- outer_zsql -----------------------
select 1 as P from dual
-------- end of outer_zsql ----------------
I understand that since I pass a P2 to inner_zsql, it should not implicitly
pick up P.
ZSQLMethod's __call__ is defined as
def __call__(self, REQUEST=None, __ick__=None, src__=0, test__=0, **kw)
and has code:
if REQUEST is None:
if kw: REQUEST=kw
else:
if hasattr(self, 'REQUEST'): REQUEST=self.REQUEST
else: REQUEST={}
so I thought if I explicitly pass a parameter (P2), ZSQL will not pick
parameters implicitly.
Any explanations?
I use DCOracle2 v1.3 with Zope 2.6.1 (binary release, python 2.1,
win32-x86), python 2.1.3, win32.