[Zope-Checkins] CVS: Zope2 - ZCatalog.py:1.92

shane@digicool.com shane@digicool.com
Thu, 21 Jun 2001 13:45:44 -0400 (EDT)


Update of /cvs-repository/Zope2/lib/python/Products/ZCatalog
In directory korak.digicool.com:/tmp/cvs-serv24737/lib/python/Products/ZCatalog

Modified Files:
	ZCatalog.py 
Log Message:
Based on some semi-formal performance tests, read guards turned out to be
slower than the old code.  With this change, we're using simple function
calls again to perform security checks.  But the calling sequence is
intended to be easier to comprehend than the old code.  Now instead of
DT_String.String subclasses having a validate() method attached to them, they
subclass AccessControl.DTML.RestrictedDTML, which provides a guarded_getattr()
method and a guarded_getitem() method.

Note that the functionality of guarded_getattr() used to be implemented
both in C and Python (in cDocumentTemplate and DT_Util), but now it's in
one place, ZopeGuards.py.  Thus it's not only reusable but easy to
optimize.

I ran all the tests and ran the new code through the profiler again.  The
change sped up restricted code a little more than expected, which is
definitely a good thing, but that may indicate that nested scopes
have a hidden speed penalty.

Also, RestrictedPython is now restrictive about printing to targets and
two forms of augmented assignment had to be forbidden.



--- Updated File ZCatalog.py in package Zope2 --
--- ZCatalog.py	2001/05/31 12:22:53	1.91
+++ ZCatalog.py	2001/06/21 17:45:13	1.92
@@ -97,7 +97,8 @@
 from DocumentTemplate.DT_Util import Eval
 from AccessControl.Permission import name_trans
 from Catalog import Catalog, CatalogError
-from AccessControl import getSecurityManager, full_read_guard
+from AccessControl import getSecurityManager
+from AccessControl.DTML import RestrictedDTML
 from zLOG import LOG, ERROR
 from ZCatalogIndexes import ZCatalogIndexes
 from Products.PluginIndexes.common.PluggableIndex import PluggableIndexInterface
@@ -846,10 +847,8 @@
     return attr
 
 
-class td(TemplateDict):
-
-    def read_guard(self, ob):
-        return full_read_guard(ob)
+class td(RestrictedDTML, TemplateDict):
+    pass
 
 def expr_match(ob, ed, c=InstanceDict, r=0):
     e, md, push, pop=ed