cleanup (shorter name, better docstring)

parent a9f0860f
...@@ -53,9 +53,12 @@ zope.deprecation.deprecated( ...@@ -53,9 +53,12 @@ zope.deprecation.deprecated(
# Path Expression uses them # Path Expression uses them
ZopeUndefs = Undefs + (NotFound, Unauthorized) ZopeUndefs = Undefs + (NotFound, Unauthorized)
def boboTraverseAwareSimpleTraverse(object, path_items, econtext): def boboAwareZopeTraverse(object, path_items, econtext):
"""A slightly modified version of zope.tales.expressions.simpleTraverse """Traverses a sequence of names, first trying attributes then items.
that interacts correctly with objects providing OFS.interfaces.ITraversable.
This uses Zope 3 path traversal where possible and interacts
correctly with objects providing OFS.interface.ITraversable when
necessary (bobo-awareness).
""" """
request = getattr(econtext, 'request', None) request = getattr(econtext, 'request', None)
path_items = list(path_items) path_items = list(path_items)
...@@ -97,7 +100,7 @@ class ZopePathExpr(PathExpr): ...@@ -97,7 +100,7 @@ class ZopePathExpr(PathExpr):
def __init__(self, name, expr, engine): def __init__(self, name, expr, engine):
super(ZopePathExpr, self).__init__(name, expr, engine, super(ZopePathExpr, self).__init__(name, expr, engine,
boboTraverseAwareSimpleTraverse) boboAwareZopeTraverse)
# override this to support different call metrics (see bottom of # override this to support different call metrics (see bottom of
# method) and Zope 2's traversal exceptions (ZopeUndefs instead of # method) and Zope 2's traversal exceptions (ZopeUndefs instead of
...@@ -232,8 +235,8 @@ class PathIterator(ZopeIterator): ...@@ -232,8 +235,8 @@ class PathIterator(ZopeIterator):
if isinstance(name, basestring): if isinstance(name, basestring):
name = name.split('/') name = name.split('/')
try: try:
ob1 = boboTraverseAwareSimpleTraverse(ob1, name, None) ob1 = boboAwareZopeTraverse(ob1, name, None)
ob2 = boboTraverseAwareSimpleTraverse(ob2, name, None) ob2 = boboAwareZopeTraverse(ob2, name, None)
except LookupError: except LookupError:
return False return False
return ob1 == ob2 return ob1 == ob2
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment