Subject: Potential tree bug (was: Re: [Zope] dtml-tree question) In-Reply-To: <117669342@toto.iv> X-Mailer: VM 6.43 under 20.4 "Emerald" XEmacs Lucid Message-ID: <14722.1760.171523.900087@lindm.dm> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Jonothan Farr writes:
What is the difference between using the dtml-tree tag in a dtml method and using it in a dtml document? I have code that works perfectly in a dtml method but when I try the exact same code in a dtml document it doesn't display anything. During rendering, the acquisition mode of a DTMLDocument is changed.
There are too acquisition modes: "implicit" and "explicit". For implicit acquisition, an attribute access "o.a" automatically searches "a" in the acquisition context of "o", too, if it cannot be found in "o". For explicit acquisition, the attribute access "o.a" looks only in "o". However, the method "aq_acquire" can be used to extend the search over the acquisition context. Usually, both DTMLMethod and DTMLDocument use implicit acquisition. DTMLDocument, however, renders with its explicit acquisition variant. This does not affect DTML code, because it uses "aq_aquire" for attribute access. However, unaware Python code may get strange effects. In your case, the tree code uses "hasattr(self,args['branches'])" to test whether the branches method exists. This fails, because due to explicit acquisition only, your SQL method in the parent is no longer seen automatically. Probably, this is a bug. But maybe, it is a feature. Dieter