[ZPT] CVS: Zope27/lib/python/Products/PageTemplates - Expressions.py:1.35.18.4

Fred L. Drake, Jr. fdrake@acm.org
Tue, 17 Sep 2002 15:24:49 -0400


Update of /cvs-repository/Zope27/lib/python/Products/PageTemplates
In directory cvs.zope.org:/tmp/cvs-serv4871

Modified Files:
      Tag: Zope-2_7-development-branch
	Expressions.py 
Log Message:
Shane points out that there's a C version of the validate2 code
available in AccessControl.cAccessControl, so use it when we can.


=== Zope27/lib/python/Products/PageTemplates/Expressions.py 1.35.18.3 => 1.35.18.4 ===
--- Zope27/lib/python/Products/PageTemplates/Expressions.py:1.35.18.3	Tue Sep 17 14:41:18 2002
+++ Zope27/lib/python/Products/PageTemplates/Expressions.py	Tue Sep 17 15:24:48 2002
@@ -46,6 +46,8 @@
 
 if sys.modules.has_key('Zope'):
     import AccessControl
+    import AccessControl.cAccessControl
+    validate2 = AccessControl.cAccessControl.aq_validate
     from AccessControl import getSecurityManager
     try:
         from AccessControl import Unauthorized
@@ -63,6 +65,12 @@
         from zExceptions import Unauthorized
     except ImportError:
         Unauthorized = "Unauthorized"
+
+    def validate2(orig, inst, name, v, real_validate):
+        if real_validate(orig, inst, name, v):
+            return 1
+        raise Unauthorized, name
+
     def call_with_ns(f, ns, arg=1):
         if arg==2:
             return f(None, ns)
@@ -335,8 +343,7 @@
             if o is not M:
                 # Check access to the attribute.
                 if has(object, 'aq_acquire'):
-                    object.aq_acquire(
-                        name, validate2, validate)
+                    object.aq_acquire(name, validate2, validate)
                 else:
                     if not validate(object, object, name, o):
                         raise Unauthorized, name
@@ -369,9 +376,3 @@
         object = o
 
     return object
-
-
-def validate2(orig, inst, name, v, real_validate):
-    if real_validate(orig, inst, name, v):
-        return 1
-    raise Unauthorized, name