Log message for revision 79432:
  We do need to do some wrapping when objects are found via namespace
  traversal.
  

Changed:
  U   Zope/branches/philikon-aq/lib/python/OFS/Traversable.py
  U   
Zope/branches/philikon-aq/lib/python/Products/Five/browser/tests/aqlegacy.py
  U   
Zope/branches/philikon-aq/lib/python/Products/Five/browser/tests/aqlegacy.zcml
  U   
Zope/branches/philikon-aq/lib/python/Products/Five/browser/tests/aqlegacy_ftest.txt
  U   Zope/branches/philikon-aq/lib/python/ZPublisher/BaseRequest.py

-=-
Modified: Zope/branches/philikon-aq/lib/python/OFS/Traversable.py
===================================================================
--- Zope/branches/philikon-aq/lib/python/OFS/Traversable.py     2007-09-01 
20:59:12 UTC (rev 79431)
+++ Zope/branches/philikon-aq/lib/python/OFS/Traversable.py     2007-09-01 
23:52:33 UTC (rev 79432)
@@ -23,6 +23,7 @@
 from AccessControl import Unauthorized
 from AccessControl.ZopeGuards import guarded_getattr
 from Acquisition import Acquired, aq_inner, aq_parent, aq_acquire, aq_base
+from Acquisition.interfaces import IAcquirer
 from zExceptions import NotFound
 from ZODB.POSException import ConflictError
 from OFS.interfaces import ITraversable
@@ -193,6 +194,8 @@
                             try:
                                 next = namespaceLookup(
                                     ns, nm, obj, aq_acquire(self, 'REQUEST'))
+                                if IAcquirer.providedBy(next):
+                                    next = next.__of__(obj)
                                 if restricted and not validate(
                                     obj, obj, name, next):
                                     raise Unauthorized(name)

Modified: 
Zope/branches/philikon-aq/lib/python/Products/Five/browser/tests/aqlegacy.py
===================================================================
--- 
Zope/branches/philikon-aq/lib/python/Products/Five/browser/tests/aqlegacy.py    
    2007-09-01 20:59:12 UTC (rev 79431)
+++ 
Zope/branches/philikon-aq/lib/python/Products/Five/browser/tests/aqlegacy.py    
    2007-09-01 23:52:33 UTC (rev 79432)
@@ -18,7 +18,10 @@
 better) still work.
 """
 import Acquisition
+import OFS.SimpleItem
+
 from zope.interface import implements
+from zope.traversing.interfaces import ITraversable
 from zope.contentprovider.interfaces import IContentProvider
 from Products.Five import BrowserView
 from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
@@ -115,3 +118,19 @@
 
     def render(self):
         return 'BrowserView viewlet'
+
+
+class LegacyNamespace(object):
+    implements(ITraversable)
+
+    def __init__(self, context, request):
+        self.context = context
+        self.request = request
+
+    def traverse(self, name, ignored):
+        return LegacyNamespaceObject(name)
+
+class LegacyNamespaceObject(OFS.SimpleItem.SimpleItem):
+
+    def __init__(self, name):
+        self.id = name

Modified: 
Zope/branches/philikon-aq/lib/python/Products/Five/browser/tests/aqlegacy.zcml
===================================================================
--- 
Zope/branches/philikon-aq/lib/python/Products/Five/browser/tests/aqlegacy.zcml  
    2007-09-01 20:59:12 UTC (rev 79431)
+++ 
Zope/branches/philikon-aq/lib/python/Products/Five/browser/tests/aqlegacy.zcml  
    2007-09-01 23:52:33 UTC (rev 79432)
@@ -112,4 +112,24 @@
       permission="zope.Public"
       />
 
+  <!-- Namespace traversal -->
+
+  <adapter
+      for="*"
+      factory=".aqlegacy.LegacyNamespace"
+      name="aqlegacy"
+      />
+  <adapter
+      for="* *"
+      factory=".aqlegacy.LegacyNamespace"
+      name="aqlegacy"
+      />
+
+  <browser:page
+      for=".aqlegacy.LegacyNamespaceObject"
+      name="index.html"
+      template="falcon.pt"
+      permission="zope.Public"
+      />
+
 </configure>
\ No newline at end of file

Modified: 
Zope/branches/philikon-aq/lib/python/Products/Five/browser/tests/aqlegacy_ftest.txt
===================================================================
--- 
Zope/branches/philikon-aq/lib/python/Products/Five/browser/tests/aqlegacy_ftest.txt
 2007-09-01 20:59:12 UTC (rev 79431)
+++ 
Zope/branches/philikon-aq/lib/python/Products/Five/browser/tests/aqlegacy_ftest.txt
 2007-09-01 23:52:33 UTC (rev 79432)
@@ -141,6 +141,28 @@
   Viewlet inheriting from Explicit</p>
 
 
+Testing namespace traversal
+===========================
+
+Namespace traversal can turn up objects during traversal without
+attribute access.  That means they might not be wrapped by default.
+Here we make sure that they are wrapped and that things like the
+request can be acquired.
+
+First let's try ``restrictedTraverse()``:
+
+  >>> foo = self.folder.restrictedTraverse('++aqlegacy++foo')
+  >>> import Acquisition
+  >>> Acquisition.aq_acquire(foo, 'REQUEST')
+  <HTTPRequest, URL=http://nohost>
+
+Now let's try URL traversal:
+
+  >>> 
browser.open('http://localhost/test_folder_1_/++aqlegacy++foo/index.html')
+  >>> print browser.contents
+  <p>The falcon has taken flight</p>
+
+
 Clean up
 --------
 

Modified: Zope/branches/philikon-aq/lib/python/ZPublisher/BaseRequest.py
===================================================================
--- Zope/branches/philikon-aq/lib/python/ZPublisher/BaseRequest.py      
2007-09-01 20:59:12 UTC (rev 79431)
+++ Zope/branches/philikon-aq/lib/python/ZPublisher/BaseRequest.py      
2007-09-01 23:52:33 UTC (rev 79432)
@@ -18,6 +18,7 @@
 import xmlrpc
 from zExceptions import Forbidden, Unauthorized, NotFound
 from Acquisition import aq_base
+from Acquisition.interfaces import IAcquirer
 
 from zope.interface import implements, providedBy, Interface
 from zope.component import queryMultiAdapter
@@ -312,6 +313,9 @@
                     ob2 = namespaceLookup(ns, nm, ob, self)
                 except TraversalError:
                     raise KeyError(ob, name)
+
+                if IAcquirer.providedBy(ob2):
+                    ob2 = ob2.__of__(ob)
                 return ob2
 
         if name == '.':

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

Reply via email to