[Zope-Checkins] SVN: Zope/trunk/ FTPServer:

Andreas Jung andreas at andreas-jung.com
Sat Dec 18 09:37:52 EST 2004


Log message for revision 28647:
  FTPServer:
  
  A RNFR (rename from) request was always responded
  with a response 350 (succesful). We do now check if the 
  source file really exists and return a 550 response in case
  if it doest not.
  
  

Changed:
  U   Zope/trunk/doc/CHANGES.txt
  U   Zope/trunk/lib/python/OFS/ObjectManager.py
  U   Zope/trunk/lib/python/ZServer/FTPRequest.py
  U   Zope/trunk/lib/python/ZServer/FTPServer.py

-=-
Modified: Zope/trunk/doc/CHANGES.txt
===================================================================
--- Zope/trunk/doc/CHANGES.txt	2004-12-17 22:06:30 UTC (rev 28646)
+++ Zope/trunk/doc/CHANGES.txt	2004-12-18 14:37:52 UTC (rev 28647)
@@ -26,6 +26,9 @@
 
     Features added
 
+      - FTPServer: a RNFR (rename from) request is now being responded
+        with a 550 error code if the source file does not exist
+
       - Fixed ObjectManager to not swallow exceptions during object
         deletion (in debug mode and if the user is not Manager). This
         allows for better debugging, while still keeping the possibility

Modified: Zope/trunk/lib/python/OFS/ObjectManager.py
===================================================================
--- Zope/trunk/lib/python/OFS/ObjectManager.py	2004-12-17 22:06:30 UTC (rev 28646)
+++ Zope/trunk/lib/python/OFS/ObjectManager.py	2004-12-18 14:37:52 UTC (rev 28647)
@@ -644,6 +644,13 @@
                 out=out+((k,stat),)
         return marshal.dumps(out)
 
+    def manage_hasId(self, REQUEST):
+        """ check if the folder has an object with REQUEST['id'] """
+
+        if not REQUEST['id'] in self.objectIds():
+            raise KeyError(REQUEST['id'])
+
+
     def manage_FTPstat(self,REQUEST):
         "Psuedo stat used for FTP listings"
         mode=0040000

Modified: Zope/trunk/lib/python/ZServer/FTPRequest.py
===================================================================
--- Zope/trunk/lib/python/ZServer/FTPRequest.py	2004-12-17 22:06:30 UTC (rev 28646)
+++ Zope/trunk/lib/python/ZServer/FTPRequest.py	2004-12-18 14:37:52 UTC (rev 28647)
@@ -98,6 +98,11 @@
                                               path, 'manage_addFolder')
             env['QUERY_STRING']='id=%s' % args[0]
 
+        elif command=='RNFR':
+            env['PATH_INFO']=self._join_paths(channel.path,
+                                              path, 'manage_hasId')
+            env['QUERY_STRING']='id=%s' % (args[0])
+
         elif command=='RNTO':
             env['PATH_INFO']=self._join_paths(channel.path,
                                               path, 'manage_renameObject')

Modified: Zope/trunk/lib/python/ZServer/FTPServer.py
===================================================================
--- Zope/trunk/lib/python/ZServer/FTPServer.py	2004-12-17 22:06:30 UTC (rev 28646)
+++ Zope/trunk/lib/python/ZServer/FTPServer.py	2004-12-18 14:37:52 UTC (rev 28647)
@@ -384,8 +384,18 @@
             self.command_not_understood (' '.join(line))
         else:
             self.fromfile = line[1]
-            self.respond ('350 RNFR command successful.')
+            pathf,idf=os.path.split(self.fromfile)
+            response=make_response(self, self.rnfr_completion)
+            request=FTPRequest(pathf,('RNFR',idf),self,response)
+            handle(self.module,request,response)
 
+    def rnfr_completion(self,response):
+        status=response.getStatus()
+        if status==200:
+            self.respond ('250 RNTO command successful.')
+        else:
+            self.respond ('550 %s: no such file or directory.' % self.fromfile)
+
     def cmd_rnto (self, line):
         if len (line) != 2:
             self.command_not_understood (' '.join(line))



More information about the Zope-Checkins mailing list