[ZPatterns] large ZPatterns bug with Zope 2.4: entirely fixed

Steve Alexander steve@cat-box.net
Sun, 08 Jul 2001 00:47:30 +0100


Steve Alexander wrote:

>
> Next, I need to look at how other parts of Zope use InstanceDict, and 
> see if I can figure out how this is all supposed to go.


Here's (what I think is...) the correct fix.
It is to make NamespaceStack in ZPatterns/Expressions.py derive from 
AccessControl.DTML.RestrictedDTML.

----

from AccessControl.DTML import RestrictedDTML


class NamespaceStack(TemplateDict, RestrictedDTML):
     """A DTML-style namespace stack, complete with Zope security
        To use, just create one with 'NamespaceStack()', then use its
       '_push()' and '_pop()' methods to add/remove mapping objects.
     If you need to push a regular object instance (ala DTML's "with"
     tag), use::
       stack._push(InstanceDict(object,stack))"""

     # Called by Zope only
     def validate(self, inst, parent, name, value, md):
         return getSecurityManager().validate(inst, parent, name, value)
----

I'll leave it as an exercise to the package maintainer how best to keep 
this working with Zope 2.3 :-)

--
Steve Alexander