[Zope-Checkins] CVS: Zope2 - DTMLMethod.py:1.67 FindSupport.py:1.25

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


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

Modified Files:
	DTMLMethod.py FindSupport.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 DTMLMethod.py in package Zope2 --
--- DTMLMethod.py	2001/06/07 22:18:44	1.66
+++ DTMLMethod.py	2001/06/21 17:45:12	1.67
@@ -100,12 +100,13 @@
 from DateTime.DateTime import DateTime
 from urllib import quote
 import  Globals, sys, Acquisition
-from AccessControl import getSecurityManager, full_read_guard
+from AccessControl import getSecurityManager
+from AccessControl.DTML import RestrictedDTML
 from Cache import Cacheable
 
 _marker = []  # Create a new marker object.
 
-class DTMLMethod(HTML, Acquisition.Implicit, RoleManager,
+class DTMLMethod(RestrictedDTML, HTML, Acquisition.Implicit, RoleManager,
                  ElementWithTitle, Item_w__name__,
                  History.Historical,
                  Cacheable,
@@ -260,9 +261,6 @@
 
     # deprecated; use get_size!
     getSize=get_size
-
-    def read_guard(self, ob):
-        return full_read_guard(ob)
 
     manage_editForm=DTMLFile('dtml/documentEdit', globals())
     manage_editForm._setName('manage_editForm')

--- Updated File FindSupport.py in package Zope2 --
--- FindSupport.py	2001/04/27 20:27:41	1.24
+++ FindSupport.py	2001/06/21 17:45:12	1.25
@@ -93,7 +93,7 @@
 from DocumentTemplate.DT_Util import InstanceDict, TemplateDict
 from DateTime import DateTime
 from string import find
-from AccessControl import getSecurityManager, full_read_guard
+from AccessControl.DTML import RestrictedDTML
 
 class FindSupport(ExtensionClass.Base):
     """Find support for Zope Folders"""
@@ -305,10 +305,8 @@
 
 
 
-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):