Log message for revision 120425:
  Resource directories now implement own traversal. This fixes an issue where a 
browser view with the same name as a subdirectory would be favored (leading to 
often very unexpected results).

Changed:
  U   Products.Five/branches/1.5/CHANGES.txt
  U   Products.Five/branches/1.5/browser/resource.py
  U   Products.Five/branches/1.5/browser/tests/resource.txt

-=-
Modified: Products.Five/branches/1.5/CHANGES.txt
===================================================================
--- Products.Five/branches/1.5/CHANGES.txt      2011-02-18 15:01:43 UTC (rev 
120424)
+++ Products.Five/branches/1.5/CHANGES.txt      2011-02-18 15:46:03 UTC (rev 
120425)
@@ -5,6 +5,10 @@
 HEAD
 ====
 
+* Resource directories now implement own traversal. This fixes an
+  issue where a browser view with the same name as a subdirectory
+  would be favored.
+
 Five 1.5.9 (2009-01-01)
 =======================
 

Modified: Products.Five/branches/1.5/browser/resource.py
===================================================================
--- Products.Five/branches/1.5/browser/resource.py      2011-02-18 15:01:43 UTC 
(rev 120424)
+++ Products.Five/branches/1.5/browser/resource.py      2011-02-18 15:46:03 UTC 
(rev 120425)
@@ -20,6 +20,7 @@
 
 import Acquisition
 from OFS.Traversable import Traversable as OFSTraversable
+from zope.publisher.interfaces import IPublishTraverse
 from zope.app.publisher.browser.resources import empty
 from zope.app.publisher.fileresource import File, Image
 from zope.app.publisher.pagetemplateresource import PageTemplate
@@ -175,6 +176,7 @@
 
 class DirectoryResource(BrowserView, Resource, OFSTraversable):
     #implements(IBrowserPublisher)
+    implements(IPublishTraverse)
 
     resource_factories = {
         'gif':  ImageResourceFactory,
@@ -199,6 +201,9 @@
             name = '++resource++%s' % self.__name__
         return name
 
+    def publishTraverse(self, request, name):
+        return self.get(name)
+
     def __browser_default__(self, request):
         '''See interface IBrowserPublisher'''
         return empty, ()

Modified: Products.Five/branches/1.5/browser/tests/resource.txt
===================================================================
--- Products.Five/branches/1.5/browser/tests/resource.txt       2011-02-18 
15:01:43 UTC (rev 120424)
+++ Products.Five/branches/1.5/browser/tests/resource.txt       2011-02-18 
15:46:03 UTC (rev 120425)
@@ -61,6 +61,20 @@
   >>> abs_url + '/' == base_url % ''
   True
 
+Verify that the resource directory implements the ``IPublishTraverse``
+interface. We want only directory-based traversal at this point
+(otherwise, if a subobject has the name of a view component, it will
+be preferred by the default traverser).
+
+  >>> directory = self.folder.unrestrictedTraverse(
+  ...     'testoid/++resource++fivetest_resources')
+  >>> from zope.publisher.interfaces import IPublishTraverse
+  >>> IPublishTraverse.providedBy(directory)
+  True
+
+  >>> directory.publishTraverse('self.folder.REQUEST', 'resource_subdir')
+  <Products.Five.browser.resource.DirectoryResource object at ...>
+
 PageTemplateResource's __call__ renders the template
 
   >>> for r in dir_resource_names:

_______________________________________________
Zope-Checkins maillist  -  Zope-Checkins@zope.org
https://mail.zope.org/mailman/listinfo/zope-checkins

Reply via email to