Re: [Zope] REPOST: dtml-with doesn't work
Philip has already made it clear that this was not his problem, but still, Dieter Maurer wrote:
Just a remark:
SQL methods do *NOT* look at the DTML namespace *AT ALL*, just at REQUEST (or the expliciitly passed keyword arguments).
Thus, "dtml-with", "dtml-let" and friends are all ineffective with respect to ZSQL methods.
My experience is somewhat different: ZSQL methods in general *DO* look at the namespace just like normal DTML methods, with two exceptions: 1) The major one, is that Dieter's remark does describe (almost) correctly the behavior of <dtml-sqlvar> and <dtml-sqltest>. These two tags only look at a very limited local namespace, initialized with the REQUEST and passed arguments; but even this namespace may be modified, *INSIDE* the ZSQL method, with <dtml-in> and <dtml-let>. However, other tags behave quite normally -- which means that a lot of the problems can be bypassed by thoughtful use of <dtml-var>, especially using the sql_quote modifier (BTW, it is by virtue of this that you can call other methods -- even other ZSQL methods -- from within a ZSQL method). 2) Changing REQUEST does *not* update the local namespace, that is, within a ZSQL method, <dtml-call "REQUEST.set('some_var', 17)"> <dtml-var some_var> doesn't work; but <dtml-var "REQUEST['some_var']"> Does. Hope this helps, Shai.
I checked the sources Shai Berger writes:
My experience is somewhat different: ZSQL methods in general *DO* look at the namespace just like normal DTML methods, with two exceptions: ZSQL methods do *NOT* look at the DTML(!) namespace.
They do look at REQUEST or (exclusive) explicitly provided keyword arguments *AND* they can acquire names from the ZSQL methods and its acquisition context.
... <dtml-sqlvar> and <dtml-sqltest> only look at a very limited local namespace, initialized with the REQUEST and passed arguments; but even this namespace may be modified, *INSIDE* the ZSQL method, with <dtml-in> and <dtml-let>. I see, I should have been more specific.
ZSQL methods do not look at the DTML namespace of the *CALLING* document template. They use a document template (to generate the query) which is evaluated in a (newly creatd) namespace. Of cause, it looks at this DTML namespace in the usual way. And all DTML tags are available to extend this namespace.
However, other tags behave quite normally -- which means that a lot of the problems can be bypassed by thoughtful use of <dtml-var>, especially using the sql_quote modifier (BTW, it is by virtue of this that you can call other methods -- even other ZSQL methods -- from within a ZSQL method). There is no difference with respect to name lookup between "dtml-var" and "dtml-sqlvar" or the other "dtml-sql*" tags. They *ALL* work with the same namespace.
2) Changing REQUEST does *not* update the local namespace, that is, within a ZSQL method, That is right. The reason is that "REQUEST" is not part of the newly generated namespace in which the ZSQL template is evaluated. "REQUEST" is acquired.
<dtml-call "REQUEST.set('some_var', 17)"> <dtml-var some_var>
doesn't work; but
<dtml-var "REQUEST['some_var']">
Does.
Dieter
participants (2)
-
Dieter Maurer -
Shai Berger