[Zope3-checkins] CVS: Zope3/src/zope/app/traversing - __init__.py:1.15
Steve Alexander
steve@cat-box.net
Mon, 31 Mar 2003 06:37:37 -0500
Update of /cvs-repository/Zope3/src/zope/app/traversing
In directory cvs.zope.org:/tmp/cvs-serv23220/zope/app/traversing
Modified Files:
__init__.py
Log Message:
Added joinPath to the module's __all__.
Replaced implementation of joinPath with a shorter and more efficient
version.
=== Zope3/src/zope/app/traversing/__init__.py 1.14 => 1.15 ===
--- Zope3/src/zope/app/traversing/__init__.py:1.14 Sun Mar 30 10:36:42 2003
+++ Zope3/src/zope/app/traversing/__init__.py Mon Mar 31 06:37:36 2003
@@ -20,16 +20,17 @@
from zope.proxy.context import getWrapperContainer, isWrapper
__all__ = ['traverse', 'traverseName', 'objectName', 'getParent',
- 'getParents', 'getPath', 'getRoot', 'canonicalPath']
+ 'getParents', 'getPath', 'getRoot', 'canonicalPath', 'joinPath']
_marker = object()
def joinPath(path, *args):
"""Concatenate a path and various args with slashes"""
- for arg in args:
- path = path.endswith('/') and '%s%s' % (path, arg) \
- or '%s/%s' % (path, arg)
- return path
+ if not args:
+ return unicode(path)
+ if path != u'/':
+ path += u'/'
+ return path + u'/'.join(args)
def getPath(obj):
"""Returns a string representing the physical path to the object.