[Zope3-checkins] CVS: Zope3/src/zope/app/traversing - __init__.py:1.17

Sidnei da Silva sidnei@x3ng.com.br
Mon, 31 Mar 2003 08:32:37 -0500


Update of /cvs-repository/Zope3/src/zope/app/traversing
In directory cvs.zope.org:/tmp/cvs-serv7402/src/zope/app/traversing

Modified Files:
	__init__.py 
Log Message:
Slight modification to joinPath, with tests.

=== Zope3/src/zope/app/traversing/__init__.py 1.16 => 1.17 ===
--- Zope3/src/zope/app/traversing/__init__.py:1.16	Mon Mar 31 06:51:22 2003
+++ Zope3/src/zope/app/traversing/__init__.py	Mon Mar 31 08:32:06 2003
@@ -31,13 +31,20 @@
     The path should be well-formed, and not end in a '/' unless it is the
     root path.
     The positional arguments are strings to be added to the path as new path
-    segments. These segments should not contain the '/' character.
+    segments. These segments may contain the '/' character.
     """
     if not args:
         return unicode(path)
-    if path != u'/':
+    if path != u'/' and not path.endswith('/'):
         path += u'/'
-    return path + u'/'.join(args)
+    clean_args = []
+    for arg in args:
+        if arg.startswith('/'):
+            arg = arg[1:]
+        if arg.endswith('/'):
+            arg = arg[:-1]
+        clean_args.append(arg)
+    return path + u'/'.join(clean_args)
 
 def getPath(obj):
     """Returns a string representing the physical path to the object.