[Checkins] SVN: z3c.pt/trunk/ - Path expressions need to pass further path items in reverse order to

Sidnei da Silva sidnei at enfoldsystems.com
Wed Mar 11 09:53:21 EDT 2009


Log message for revision 97837:
  - Path expressions need to pass further path items in reverse order to
    traversePathElement, because that's what it expects.
  
  

Changed:
  U   z3c.pt/trunk/CHANGES.txt
  U   z3c.pt/trunk/src/z3c/pt/README.txt
  U   z3c.pt/trunk/src/z3c/pt/expressions.py
  U   z3c.pt/trunk/src/z3c/pt/tests/function_namespaces.pt

-=-
Modified: z3c.pt/trunk/CHANGES.txt
===================================================================
--- z3c.pt/trunk/CHANGES.txt	2009-03-11 11:26:45 UTC (rev 97836)
+++ z3c.pt/trunk/CHANGES.txt	2009-03-11 13:53:20 UTC (rev 97837)
@@ -6,6 +6,9 @@
 - Path expressions give preference to dictionary items instead of
   dictionary attributes. [sidnei, malthe]
 
+- Path expressions need to pass further path items in reverse order to
+  traversePathElement, because that's what it expects. [sidnei]
+
 1.0b12 (2009/03/09)
 ~~~~~~~~~~~~~~~~~~~
 

Modified: z3c.pt/trunk/src/z3c/pt/README.txt
===================================================================
--- z3c.pt/trunk/src/z3c/pt/README.txt	2009-03-11 11:26:45 UTC (rev 97836)
+++ z3c.pt/trunk/src/z3c/pt/README.txt	2009-03-11 13:53:20 UTC (rev 97837)
@@ -117,6 +117,7 @@
     <span>test</span>
   </div>
 
+
 Dollar-Interpolation
 --------------------
 
@@ -348,7 +349,7 @@
 remaining path instead::
 
   >>> from zope.traversing.interfaces import TraversalError
-  
+
   >>> class ns4(object):
   ...     zope.interface.implements(ITraversable)
   ...
@@ -374,6 +375,20 @@
   >>> zope.component.getGlobalSiteManager().registerAdapter(
   ...     ns4, [zope.interface.Interface], IPathAdapter, 'ns4')
 
+  >>> class ns5(object):
+  ...     zope.interface.implements(ITraversable)
+  ...
+  ...     def __init__(self, context):
+  ...         self.context = context
+  ...
+  ...     def traverse(self, name, furtherPath):
+  ...	      name = '/'.join([name] + furtherPath[::-1])
+  ...	      del furtherPath[:]
+  ...	      return 'traversed: ' + name
+
+  >>> zope.component.getGlobalSiteManager().registerAdapter(
+  ...     ns5, [zope.interface.Interface], IPathAdapter, 'ns5')
+
   >>> class Ob(object):
   ...     def __init__(self, title, date, parent=None, child=None):
   ...         self.title = title
@@ -408,4 +423,5 @@
     <span>called page: another</span>
     <span>traversed: zope.Public</span>
     <span>traversed: text-to-html</span>
+    <span>traversed: page/yet/even/another</span>
   </div>

Modified: z3c.pt/trunk/src/z3c/pt/expressions.py
===================================================================
--- z3c.pt/trunk/src/z3c/pt/expressions.py	2009-03-11 11:26:45 UTC (rev 97836)
+++ z3c.pt/trunk/src/z3c/pt/expressions.py	2009-03-11 13:53:20 UTC (rev 97837)
@@ -47,9 +47,10 @@
 
         if bool(path_items):
             path_items = list(path_items)
+            path_items.reverse()
 
             while len(path_items):
-                name = path_items.pop(0)
+                name = path_items.pop()
                 ns = ':' in name
                 if ns is True:
                     namespace, name = name.split(':', 1)
@@ -64,7 +65,7 @@
                     next = base.get(name, _marker)
                 else:
                     next = getattr(base, name, _marker)
-                
+
                 if next is not _marker:
                     base = next
                     if ns is True and isinstance(base, MethodType):

Modified: z3c.pt/trunk/src/z3c/pt/tests/function_namespaces.pt
===================================================================
--- z3c.pt/trunk/src/z3c/pt/tests/function_namespaces.pt	2009-03-11 11:26:45 UTC (rev 97836)
+++ z3c.pt/trunk/src/z3c/pt/tests/function_namespaces.pt	2009-03-11 13:53:20 UTC (rev 97837)
@@ -8,4 +8,5 @@
   <span tal:content="context/ns4:page/yet/another|nothing" />
   <span tal:content="context/ns4:zope.Public" />
   <span tal:content="context/ns4:text-to-html" />
+  <span tal:content="context/ns5:page/yet/even/another" />
 </div>



More information about the Checkins mailing list