[ZPT] CVS: Zope/lib/python/Products/PageTemplates - Expressions.py:1.36.6.3

Shane Hathaway shane@cvs.zope.org
Wed, 18 Sep 2002 11:50:32 -0400


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

Modified Files:
      Tag: Zope-2_6-branch
	Expressions.py 
Log Message:
Merge from head.

Finished fix for collector #558.  restrictedTraverse() was not providing
adequate context for the security manager, resulting in excessive Unauthorized
errors.  The previous fix corrected traversal using __bobo_traverse__();
this fix corrects traversal using getattr().  The problem was solved by
simply making use of AccessControl.ZopeGuards.guarded_getattr().


=== Zope/lib/python/Products/PageTemplates/Expressions.py 1.36.6.2 => 1.36.6.3 ===
--- Zope/lib/python/Products/PageTemplates/Expressions.py:1.36.6.2	Wed Sep 18 10:54:11 2002
+++ Zope/lib/python/Products/PageTemplates/Expressions.py	Wed Sep 18 11:50:32 2002
@@ -47,6 +47,7 @@
 if sys.modules.has_key('Zope'):
     import AccessControl
     from AccessControl import getSecurityManager
+    from AccessControl.ZopeGuards import guarded_getattr
     try:
         from AccessControl import Unauthorized
     except ImportError:
@@ -59,6 +60,7 @@
              call_with_ns
 else:
     from PythonExpr import getSecurityManager, PythonExpr
+    guarded_getattr = getattr
     try:
         from zExceptions import Unauthorized
     except ImportError:
@@ -331,16 +333,8 @@
                 raise Unauthorized, name
         else:
             # Try an attribute.
-            o = get(object, name, M)
-            if o is not M:
-                # Check access to the attribute.
-                if has(object, 'aq_acquire'):
-                    object.aq_acquire(
-                        name, validate2, validate)
-                else:
-                    if not validate(object, object, name, o):
-                        raise Unauthorized, name
-            else:
+            o = guarded_getattr(object, name, M)
+            if o is M:
                 # Try an item.
                 try:
                     # XXX maybe in Python 2.2 we can just check whether