[Zope-dev] Zope 2.4.2 DTML Method Bug

Steve Alexander steve@cat-box.net
Wed, 31 Oct 2001 18:08:02 +0000


Casey Duncan wrote:

> One of my products exposed a bug in the 2.4.2 version of DTMLMethod.py. It is 
> minor and can be worked around, but I wanted to point it out:
> 
> Line 203 of DTMLMethod.py now contains:
> 
> del self.__dict__['validate']
> 
> which is part of a try...finally statement.
> 
> It seems that the "validate" key is not always present in the object at that 
> point, specifically if you recursively call an object in a different context 
> then it was originally called. as in:
> 
> <dtml-with name="something">
>   <dtml-return name="this">
> </dtml-with>
> 
> This piece of code resulted in a KeyError on "validate" in my product code, 
> which had previously worked fine. Perhaps another try statement should be 
> wrapped around this del statement?


This happens when a dtml method is reentrant.

The fix needs to be a bit deeper than what you describe above, otherwise 
you'll potentially lose the "validate" attribute of the dtml method 
object, and you'll get strange errors.

I've put this into the new collector, with a patch:


   http://new.zope.org/Collector/4

--
Steve Alexander
Software Engineer
Cat-Box limited