[Zope] REPOST: dtml-with doesn't work

Dieter Maurer dieter@handshake.de
Sun, 14 Jan 2001 22:17:16 +0100 (CET)


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