[Checkins] SVN: z3c.pt/trunk/ If a namespace-acquired object is traversable, use path traversal on it.

Malthe Borch mborch at gmail.com
Tue Mar 3 04:30:22 EST 2009


Log message for revision 97437:
  If a namespace-acquired object is traversable, use path traversal on it.

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

-=-
Modified: z3c.pt/trunk/CHANGES.txt
===================================================================
--- z3c.pt/trunk/CHANGES.txt	2009-03-03 09:28:48 UTC (rev 97436)
+++ z3c.pt/trunk/CHANGES.txt	2009-03-03 09:30:22 UTC (rev 97437)
@@ -3,6 +3,9 @@
 
 In next release
 
+- If a namespace-acquired object provides ``ITraversable``, use path
+  traversal. [malthe]
+
 - Implemented TALES function namespaces. [sidnei, malthe]
 
 - Catch ``NameError`` in exists-traverser (return false). [malthe]

Modified: z3c.pt/trunk/src/z3c/pt/expressions.py
===================================================================
--- z3c.pt/trunk/src/z3c/pt/expressions.py	2009-03-03 09:28:48 UTC (rev 97436)
+++ z3c.pt/trunk/src/z3c/pt/expressions.py	2009-03-03 09:30:22 UTC (rev 97437)
@@ -5,6 +5,7 @@
 from zope.traversing.adapters import traversePathElement
 from zope.contentprovider.interfaces import IContentProvider
 from zope.contentprovider.interfaces import ContentProviderLookupError
+from zope.traversing.interfaces import ITraversable
 
 try:
     from zope.contentprovider.interfaces import BeforeUpdateEvent
@@ -53,9 +54,11 @@
                 if ns is True:
                     namespace, name = name.split(':', 1)
                     base = namespaces.function_namespaces[namespace](base)
-                # XXX Need to check for ITraversable on 'base' here
-                # and use traversePathElement instead of getattr. See
-                # failing test.
+                    if ITraversable.providedBy(base):
+                        base = self.proxify(traversePathElement(
+                            base, name, path_items, request=request))
+                        continue
+                    
                 next = getattr(base, name, _marker)
                 if next is not _marker:
                     base = next



More information about the Checkins mailing list