[Zope-Checkins] CVS: Zope3/lib/python/Zope/Server/FTP - FTPServerChannel.py:1.1.2.25

Shane Hathaway shane@cvs.zope.org
Fri, 12 Apr 2002 15:14:14 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/Server/FTP
In directory cvs.zope.org:/tmp/cvs-serv6963

Modified Files:
      Tag: Zope3-Server-Branch
	FTPServerChannel.py 
Log Message:
Always use posixpath instead of os.path, since we always want slashes in
paths, even on Windows.


=== Zope3/lib/python/Zope/Server/FTP/FTPServerChannel.py 1.1.2.24 => 1.1.2.25 ===
 """
 
-import os
+import posixpath
 import stat
 import sys
 import socket
@@ -382,7 +382,7 @@
             # The actually write should be transactional without
             # holding up the application.
             fs = self._getFilesystem()
-            fs.check_writable(path, mode)
+            fs.check_writable(path)
         except OSError, err:
             self.reply('ERR_OPEN_WRITE', str(err))
             return
@@ -457,13 +457,10 @@
 
     def _generatePath(self, args):
         """Convert relative paths to absolute paths."""
-        if args.startswith('/'):
-            path = args
-        else:
-            path = os.path.join(self.cwd, args)
-            if path.startswith('..'):
-                path = '/'
-        return os.path.normpath(path)
+        # We use posixpath even on non-Posix platforms because we don't want
+        # slashes converted to backslashes.
+        path = posixpath.join(self.cwd, args)
+        return posixpath.normpath(path)
 
 
     def newPassiveAcceptor(self):
@@ -498,7 +495,7 @@
         else:
             dir = path_args[0]
 
-        dir = os.path.join(self.cwd, dir)
+        dir = self._generatePath(dir)
         return self.listdir(dir, long)