[Zope-Checkins] CVS: Zope/lib/python/OFS - DTMLDocument.py:1.44.54.1 DTMLMethod.py:1.69.8.1

Jim Fulton jim@zope.com
Fri, 19 Oct 2001 15:08:47 -0400


Update of /cvs-repository/Zope/lib/python/OFS
In directory cvs.zope.org:/tmp/cvs-serv9149

Modified Files:
      Tag: cAccessControl-review-branch
	DTMLDocument.py DTMLMethod.py 
Log Message:
Fixed bug in caching of the security-manager DTMLValidate method.
Basically we need to keep the slower validate method to fall back
on if the (primitive) cache is cleared in a recursive call.
Also made the cahe clearing code resiliant to getting called in the 
wrong order, but putting a exception swallower around the __dict__
item deletion. 


=== Zope/lib/python/OFS/DTMLDocument.py 1.44 => 1.44.54.1 ===
         security=getSecurityManager()
         security.addContext(self)
-
+        self.__dict__['validate'] = security.DTMLValidate
         try:
             if client is None:
                 # Called as subtemplate, so don't need error propigation!
@@ -202,7 +202,10 @@
                     self.ZCacheable_set(r)
                 return r
 
-        finally: security.removeContext(self)
+        finally:
+            security.removeContext(self)
+            try: del self.__dict__['validate']
+            except: pass
 
         have_key=RESPONSE.headers.has_key
         if not (have_key('content-type') or have_key('Content-Type')):


=== Zope/lib/python/OFS/DTMLMethod.py 1.69 => 1.69.8.1 ===
         finally:
             security.removeContext(self)
-            del self.__dict__['validate']
+            try: del self.__dict__['validate']
+            except: pass
 
         have_key=RESPONSE.headers.has_key
         if not (have_key('content-type') or have_key('Content-Type')):
@@ -213,6 +214,9 @@
         if not self._cache_namespace_keys:
             self.ZCacheable_set(result)
         return result
+
+    def validate(self, inst, parent, name, value, md=None):
+        return getSecurityManager().validate(inst, parent, name, value)
 
     def ZDocumentTemplate_beforeRender(self, md, default):
         # Tries to get a cached value.