ZSQL argument passing
While iterating over the results of a ZSQL method, which includes a fieldname "userid" I call another ZSQL method like so, passwdGetUser(username=_.SecurityGetUser) passwdGetUser takes two optional arguments "username" and "userid", select * from passwd <dtml-sqlgroup where> <dtml-sqltest userid type=int optional> <dtml-and> <dtml-sqltest username type=nb optional> </dtml-sqlgroup> When called like above, passwdGetUser(username=_.SecurityGetUser) I found that some times this wouldn't return anything. Investigation turned 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 this problem by calling, passwdGetUser(username=_.SecurityGetUser, userid='') To me, this is non-obvious and I'm wondering why this is happening, and if it's meant to. -- Bryan C. Andregg Duke University Medical Center Programmer Dept. of Anesthesiology e <bryan.andregg@duke.edu> p +1 919 684 6201
Hi. * Bryan C. Andregg <bryan.andregg@duke.edu> [020313 14:41]:
While iterating over the results of a ZSQL method, which includes a fieldname "userid" I call another ZSQL method like so,
passwdGetUser(username=_.SecurityGetUser)
passwdGetUser takes two optional arguments "username" and "userid",
select * from passwd <dtml-sqlgroup where> <dtml-sqltest userid type=int optional> <dtml-and> <dtml-sqltest username type=nb optional> </dtml-sqlgroup>
When called like above,
passwdGetUser(username=_.SecurityGetUser)
I found that some times this wouldn't return anything. Investigation turned 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 this problem by calling,
passwdGetUser(username=_.SecurityGetUser, userid='')
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 currently because it is broken for "None" Variables, but will work with empty strings. Greetings Christian -- 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'])
And btw: i had some problems with ppl not reading my mail because signing it, you should probably turn it off when posting to the list ... using a good MUA will make that easy. * Bryan C. Andregg <bryan.andregg@duke.edu> [020313 14:41]:
While iterating over the results of a ZSQL method, which includes a fieldname "userid" I call another ZSQL method like so,
passwdGetUser(username=_.SecurityGetUser)
passwdGetUser takes two optional arguments "username" and "userid",
select * from passwd <dtml-sqlgroup where> <dtml-sqltest userid type=int optional> <dtml-and> <dtml-sqltest username type=nb optional> </dtml-sqlgroup>
When called like above,
passwdGetUser(username=_.SecurityGetUser)
I found that some times this wouldn't return anything. Investigation turned 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 this problem by calling,
passwdGetUser(username=_.SecurityGetUser, userid='')
To me, this is non-obvious and I'm wondering why this is happening, and if it's meant to. -- Bryan C. Andregg Duke University Medical Center Programmer Dept. of Anesthesiology e <bryan.andregg@duke.edu> p +1 919 684 6201
-- 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'])
Bryan C. Andregg writes:
passwdGetUser(username=_.SecurityGetUser)
passwdGetUser takes two optional arguments "username" and "userid", ... When called like above,
passwdGetUser(username=_.SecurityGetUser)
I found that some times this wouldn't return anything. Investigation turned 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 this problem by calling,
passwdGetUser(username=_.SecurityGetUser, userid='')
To me, this is non-obvious and I'm wondering why this is happening, and if it's meant to. What Zope version do you use?
In my Zope CVS (from end of January 2002), I still have: def __call__(self, REQUEST=None, __ick__=None, src__=0, test__=0, **kw): .... if REQUEST is None: if kw: REQUEST=kw else: if hasattr(self, 'REQUEST'): REQUEST=self.REQUEST else: REQUEST={} This means, that you do not get arguments from "REQUEST" when you pass any keyword parameters (other than "__ick__", "src__", "test__" or "REQUEST"). You never get arguments from the DTML namespace. But, you may still get arguments from acquisition (even when you pass keyword parameters). Dieter
On Wed, Mar 13, 2002 at 10:47:12PM +0100, Dieter Maurer mailed:
What Zope version do you use?
2.4.3
In my Zope CVS (from end of January 2002), I still have:
def __call__(self, REQUEST=None, __ick__=None, src__=0, test__=0, **kw): .... if REQUEST is None: if kw: REQUEST=kw else: if hasattr(self, 'REQUEST'): REQUEST=self.REQUEST else: REQUEST={}
This means, that you do not get arguments from "REQUEST" when you pass any keyword parameters (other than "__ick__", "src__", "test__" or "REQUEST").
You never get arguments from the DTML namespace.
But, you may still get arguments from acquisition (even when you pass keyword parameters).
I'm guessing that they come from acquisition, but I'm still working on the advanced parts of that concept somewhere in the back of my brain. -- Bryan C. Andregg Duke University Medical Center Programmer Dept. of Anesthesiology e <bryan.andregg@duke.edu> p +1 919 684 6201
participants (3)
-
Bryan C. Andregg -
Christian Theune -
Dieter Maurer