[Zope] DTML namespace weirdness

Andrew Snare ajs@pigpond.com
Fri, 28 Apr 2000 12:24:02 +1000


Hi people,

I've recently noticed some weirdness with namespace lookups in various
dtml contexts. In particular, I've noticed the following problems:

1) REQUEST isn't being passed through to ZSQL methods.

	People have commented that this is a result of the security
	updates introduced around the time of 2.1.5. I also note that
	the ZSQL documentation doesn't state REQUEST should be
	available, but I guess we're used to it being around.

2) The order of namespace lookups in ZSQL Methods appear to have
   changed.

	I've noticed that when referring to variables with <dtml-sqlvar
	variable type=string>, variable will be acquired in preference
	to a parameter listed for the ZSQL Method. As an example, I had
	a ZSQL Method within a folder called "action" that also had a
	listed parameter of the same name. The method did a database
	insertion, but instead of inserting the text passed via the
	"action" parameter for the method, it would appear the folder
	named "action" was acquired in preference, resulting in the
	database containing the text "<Action instance at blah>" (ok, so
	it wasn't really a folder but rather a Product class called
	Action).

3) Namespace collisions within ZSQL Methods.

	It would appear that using parameters with some names causes
	grief, possibly due to internal names. In particular naming a
	parameter "status" caused me grief when trying to reference it
	with <dtml-sqlvar status type=int>. This could be related to the
	previous point, with a collision occuring with the Status
	attribute of the RESPONSE object -- I don't know if RESPONSE is
	in the namespace though.

4) The order of namespace lookups in DTML methods has also changed.

	I'm not so sure of this one. But I think I've found that the
	following DTML setup won't work as expected:
	<dtml-in "getSQL(foo)">
	  <dtml-var name>
	  <dtml-in "getSQL(bar)">
	    <dtml-var name>
	  </dtml-in>
	</dtml-in>
	The innermost <dtml-var name> picks up name from the outter
	query, not the inner one. Again, this could be related to some
	changes in the way ZSQL Methods work but I found the behaviour
	most surprising.

Is anyone else able to confirm these results, and classify them as
either expected, buggy, undocumentated or whatever kinds of behaviour?
:)

As background, this behaviour is being observed within a Product
developed under Zope 2.0.1 and these are some of the problems that have
come to light after migrating to Zope 2.1.6.

Regards,

 - Andrew