[Zope-Checkins] SVN: Products.Five/branches/1.2/ Backported Zope 2.10 traversal order changes.

Alec Mitchell apm13 at columbia.edu
Thu Jul 13 20:07:00 EDT 2006


Log message for revision 69123:
  Backported Zope 2.10 traversal order changes.
  

Changed:
  U   Products.Five/branches/1.2/CHANGES.txt
  U   Products.Five/branches/1.2/browser/tests/test_traversable.py
  U   Products.Five/branches/1.2/traversable.py

-=-
Modified: Products.Five/branches/1.2/CHANGES.txt
===================================================================
--- Products.Five/branches/1.2/CHANGES.txt	2006-07-13 23:57:56 UTC (rev 69122)
+++ Products.Five/branches/1.2/CHANGES.txt	2006-07-14 00:06:59 UTC (rev 69123)
@@ -2,6 +2,14 @@
 Five Changes
 ============
 
+Five 1.2.6 (unreleased)
+=======================
+
+* Backported the new traversal lookup order from Zope 2.10 (attribute, adapter,
+  acquired attribute).
+  request attribute that keeps Localizers list of preferred languages
+  did not exist.
+
 Five 1.2.5 (2006-05-29)
 =======================
 

Modified: Products.Five/branches/1.2/browser/tests/test_traversable.py
===================================================================
--- Products.Five/branches/1.2/browser/tests/test_traversable.py	2006-07-13 23:57:56 UTC (rev 69122)
+++ Products.Five/branches/1.2/browser/tests/test_traversable.py	2006-07-14 00:06:59 UTC (rev 69123)
@@ -216,6 +216,13 @@
       ...       attribute="eagle"
       ...       permission="zope2.Public"
       ...       />
+      ...   <browser:page
+      ...       name="mouse"
+      ...       for="OFS.interfaces.IObjectManager"
+      ...       class="Products.Five.browser.tests.pages.SimpleView"
+      ...       attribute="mouse"
+      ...       permission="zope2.Public"
+      ...       />
       ...   <five:traversable class="OFS.Application.Application"/>
       ... </configure>'''
       >>> import Products.Five
@@ -273,6 +280,27 @@
       ...
       The eagle has landed
 
+    However, acquired attributes *should* be shadowed. See discussion on
+    http://codespeak.net/pipermail/z3-five/2006q2/001474.html
+
+      >>> manage_addIndexSimpleContent(self.folder, 'mouse', 'Mouse')
+
+      >>> print http(r'''
+      ... GET /test_folder_1_/mouse HTTP/1.1
+      ...
+      ... ''')
+      HTTP/1.1 200 OK
+      ...
+      Default index_html called
+
+      >>> print http(r'''
+      ... GET /test_folder_1_/ftf/mouse HTTP/1.1
+      ...
+      ... ''')
+      HTTP/1.1 200 OK
+      ...
+      The mouse has been eaten by the eagle
+
     Clean up:
 
       >>> from zope.app.tests.placelesssetup import tearDown

Modified: Products.Five/branches/1.2/traversable.py
===================================================================
--- Products.Five/branches/1.2/traversable.py	2006-07-13 23:57:56 UTC (rev 69122)
+++ Products.Five/branches/1.2/traversable.py	2006-07-14 00:06:59 UTC (rev 69123)
@@ -23,10 +23,13 @@
 from zope.app.traversing.adapters import DefaultTraversable
 from zope.app.traversing.adapters import traversePathElement
 
+from Acquisition import aq_base
 import Products.Five.security
 from zExceptions import NotFound
 from ZPublisher import xmlrpc
 
+_marker = object()
+
 class FakeRequest(dict):
     implements(IBrowserRequest)
 
@@ -72,12 +75,12 @@
                 except AttributeError:
                     pass
         else:
-            try:
+            # See if the object itself has the attribute, try acquisition
+            # later
+            if getattr(aq_base(self), name, _marker) is not _marker:
                 return getattr(self, name)
-            except AttributeError:
-                pass
-
             try:
+                # item access should never acquire
                 return self[name]
             except (KeyError, IndexError, TypeError, AttributeError):
                 pass
@@ -111,7 +114,8 @@
                 AttributeError, KeyError, NotFound):
             pass
 
-        raise AttributeError, name
+        # Fallback on acquisition, let it raise an AttributeError if it must
+        return getattr(self, name)
 
     __bobo_traverse__.__five_method__ = True
 



More information about the Zope-Checkins mailing list