[Checkins] SVN: Products.CMFCore/trunk/Products/CMFCore/tests/base/dummy.py - extend DummyObject restrictedTraverse in a backwards-compatible way
Jens Vagelpohl
jens at dataflake.org
Sun May 17 07:53:25 EDT 2009
Log message for revision 100022:
- extend DummyObject restrictedTraverse in a backwards-compatible way
to support paths with slashes in them
Changed:
U Products.CMFCore/trunk/Products/CMFCore/tests/base/dummy.py
-=-
Modified: Products.CMFCore/trunk/Products/CMFCore/tests/base/dummy.py
===================================================================
--- Products.CMFCore/trunk/Products/CMFCore/tests/base/dummy.py 2009-05-17 11:44:08 UTC (rev 100021)
+++ Products.CMFCore/trunk/Products/CMFCore/tests/base/dummy.py 2009-05-17 11:53:24 UTC (rev 100022)
@@ -54,8 +54,18 @@
return self._id
def restrictedTraverse( self, path ):
- return path and getattr( self, path ) or self
+ if not path:
+ return self
+ parent = self
+ path_elements = path.split('/')
+ path_elements.reverse()
+ while path_elements:
+ path_element = path_elements.pop()
+ parent = getattr(parent, path_element)
+
+ return parent
+
def getIcon( self, relative=0 ):
return 'Site: %s' % relative
More information about the Checkins
mailing list