[Zope] dtml-with this only broken?

Dieter Maurer dieter@handshake.de
Sat, 24 Mar 2001 20:40:59 +0100 (CET)


Ron Bickers writes:
 > "Note
 > I was tempted to use the only argument to achieve this. However, this
 > argument is almost unusable. You probably should forget about it."
I exagerated a bit...

  Ususally, one need more than a single object to perform the task in
  hand.
     In the above case, I think (did not reread), I had needed
     REQUEST as well.
  "with" supports this only weakly.
  
     I would have to use

       <dtml-with expr="_.namespace(REQUEST=REQUEST,
                        myobject=interesting_object)" only>
	  <dtml-with myobject>
	    ....
	  </dmtl-with>
       </dtml-with>

 > Is it true, then, that even though this() is the only namespace in the
 > stack, acquisition is still effective and thus my attribute is still being
 > acquired?
Yes, because DTML namespace lookup and acquisition are orthogonal.

   It is the object that returns its acquired attributes and not the
   DTML namespace.

   "with" operates on the DTML namespace.

 > If this is the case, is there a simple way to use dtml-with and
 > get only this() without acquisition?
You have been told to use "aq_explicit".

  This will almost always work, but there are bad cases.
  You may search the (searchable) mailing list for a post from
  me with subject "surprising acquisition behaviour" (or something like
  that). It will give you some feeling when it may not work,
  though the post might only be understandable by acquisition
  experts.

I know only of a single fail safe approach: "aq_base".
For security reasons, you cannot use it from DTML,
you need an ExternalMethod.
You find posts on this in the searchable mail archives, too.


Dieter