[Zope-Checkins] CVS: Zope2 - special_dtml.py:1.18

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


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

Modified Files:
	special_dtml.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 special_dtml.py in package Zope2 --
--- special_dtml.py	2001/06/07 22:18:43	1.17
+++ special_dtml.py	2001/06/21 17:45:12	1.18
@@ -184,7 +184,8 @@
         cns = bound_data['caller_namespace']
         ns = self._Bindings_ns_class()
         push = ns._push
-        ns.read_guard = None
+        ns.guarded_getattr = None
+        ns.guarded_getitem = None
         
         req = None
         kw_bind = kw