[Zope-Checkins] SVN: Products.Five/branches/1.3/ Backported Zope
2.10 change in traversal order
Alec Mitchell
apm13 at columbia.edu
Thu Jul 13 19:57:57 EDT 2006
Log message for revision 69122:
Backported Zope 2.10 change in traversal order
Changed:
U Products.Five/branches/1.3/CHANGES.txt
U Products.Five/branches/1.3/browser/tests/test_traversable.py
U Products.Five/branches/1.3/traversable.py
-=-
Modified: Products.Five/branches/1.3/CHANGES.txt
===================================================================
--- Products.Five/branches/1.3/CHANGES.txt 2006-07-13 23:48:00 UTC (rev 69121)
+++ Products.Five/branches/1.3/CHANGES.txt 2006-07-13 23:57:56 UTC (rev 69122)
@@ -8,6 +8,9 @@
Bugfixes
--------
+* Backported the new traversal lookup order from Zope 2.10 (attribute, adapter,
+ acquired attribute).
+
* fiveconfigure.py: Removed import of deprecated 'LOG' object from 'zLOG'
in favor of the facilities provided by Python's 'logging' module.
Modified: Products.Five/branches/1.3/browser/tests/test_traversable.py
===================================================================
--- Products.Five/branches/1.3/browser/tests/test_traversable.py 2006-07-13 23:48:00 UTC (rev 69121)
+++ Products.Five/branches/1.3/browser/tests/test_traversable.py 2006-07-13 23:57:56 UTC (rev 69122)
@@ -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.testing.placelesssetup import tearDown
Modified: Products.Five/branches/1.3/traversable.py
===================================================================
--- Products.Five/branches/1.3/traversable.py 2006-07-13 23:48:00 UTC (rev 69121)
+++ Products.Five/branches/1.3/traversable.py 2006-07-13 23:57:56 UTC (rev 69122)
@@ -26,10 +26,13 @@
from zope.app.publication.browser import setDefaultSkin
from zope.app.interface import queryType
+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
@@ -112,7 +115,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