[Zope] ZSQL argument passing

Christian Theune ct@gocept.com
Wed, 13 Mar 2002 21:38:38 +0100


--osDK9TLjxFScVI/L
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Hi.

* Bryan C. Andregg <bryan.andregg@duke.edu> [020313 14:41]:
> While iterating over the results of a ZSQL method, which includes a field=
name
> "userid" I call another ZSQL method like so,
>=20
>   passwdGetUser(username=3D_.SecurityGetUser)
>=20
>   passwdGetUser takes two optional arguments "username" and "userid",
>=20
>     select * from passwd
>     <dtml-sqlgroup where>
>       <dtml-sqltest userid type=3Dint optional>
>     <dtml-and>
>       <dtml-sqltest username type=3Dnb optional>
>     </dtml-sqlgroup>
>=20
> When called like above,
>=20
>   passwdGetUser(username=3D_.SecurityGetUser)
>=20
> I found that some times this wouldn't return anything. Investigation turn=
ed up
> that since "userid" is set in the outer iteration it gets passed to
> passwdGetUser even though it's not explicitly in the statement. I solve t=
his
> problem by calling,
>=20
>   passwdGetUser(username=3D_.SecurityGetUser, userid=3D'')
>=20
> To me, this is non-obvious and I'm wondering why this is happening, and if
> it's meant to.


Actually it *is* intended to act this way, as this is what is meant with
"acquisition by context". Btw: be careful with the optional attribute curre=
ntly
because it is broken for "None" Variables, but will work with empty strings.

Greetings

Christian

--=20
Christian Theune - ct@gocept.com
gocept gmbh & co.kg - schalaunische strasse 6 - 06366 koethen/anhalt
tel.+49 3496 3099112 - fax.+49 3496 3099118 mob. - 0178 48 33 981

reduce(lambda x,y:x+y,[chr(ord(x)^42) for x in 'zS^BED\nX_FOY\x0b'])

--osDK9TLjxFScVI/L
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE8j7jNdUt9X/gknwIRAnZiAJ9X3UdkTCnKbGXXeM1TbdQyt+l6ogCfdb/J
TDl2v+D4aEPZpkcHop713a4=
=j2vE
-----END PGP SIGNATURE-----

--osDK9TLjxFScVI/L--