Re: [Zope] dtml-with this only broken?
Ron Bickers writes:
It seems that <dtml-with "this()" only> doesn't do what one would expect. My 'description' is still being acquired. I found in the mailing list that I can use something like <dtml-if "_.hasattr(aq_explicit, 'description')">, but why doesn't the with only work? Please read the sections "Name Lookup" and "DTML -> Commands -> with" in
URL:http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html You will probably recognize that the expectations were wrong.... Dieter
Ok... I think I might understand now, but what do you mean by this? What is it almost unusable? "Note I was tempted to use the only argument to achieve this. However, this argument is almost unusable. You probably should forget about it." 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? If this is the case, is there a simple way to use dtml-with and get only this() without acquisition? _______________________ Ron Bickers Logic Etc, Inc. rbickers@logicetc.com
-----Original Message----- From: Dieter Maurer [mailto:dieter@handshake.de] Sent: Friday, March 23, 2001 2:20 PM To: Ron Bickers Cc: zope@zope.org Subject: Re: [Zope] dtml-with this only broken?
Ron Bickers writes:
It seems that <dtml-with "this()" only> doesn't do what one would expect. My 'description' is still being acquired. I found in the mailing list that I can use something like <dtml-if "_.hasattr(aq_explicit, 'description')">, but why doesn't the with only work? Please read the sections "Name Lookup" and "DTML -> Commands -> with" in
URL:http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html
You will probably recognize that the expectations were wrong....
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
participants (2)
-
Dieter Maurer -
Ron Bickers