[Zope-Checkins] SVN: Zope/branches/2.12/ - LP #418454: FTP server did not work with Python 2.6.X

Andreas Jung andreas at andreas-jung.com
Mon Aug 31 09:03:19 EDT 2009


Log message for revision 103397:
  
  - LP #418454: FTP server did not work with Python 2.6.X
  
  

Changed:
  U   Zope/branches/2.12/doc/CHANGES.rst
  U   Zope/branches/2.12/src/ZServer/FTPServer.py

-=-
Modified: Zope/branches/2.12/doc/CHANGES.rst
===================================================================
--- Zope/branches/2.12/doc/CHANGES.rst	2009-08-31 13:00:16 UTC (rev 103396)
+++ Zope/branches/2.12/doc/CHANGES.rst	2009-08-31 13:03:19 UTC (rev 103397)
@@ -48,6 +48,8 @@
 Bugs Fixed
 ++++++++++
 
+- LP #418454: FTP server did not work with Python 2.6.X
+
 - PythonScript: Fixed small Python 2.6 compatibility issue.
 
 - mkzopeinstance: Made instance scripts more suitable for egg based installs.

Modified: Zope/branches/2.12/src/ZServer/FTPServer.py
===================================================================
--- Zope/branches/2.12/src/ZServer/FTPServer.py	2009-08-31 13:00:16 UTC (rev 103396)
+++ Zope/branches/2.12/src/ZServer/FTPServer.py	2009-08-31 13:03:19 UTC (rev 103397)
@@ -64,6 +64,7 @@
 
 """
 
+import sys
 from PubCore import handle
 from medusa.ftp_server import ftp_channel, ftp_server, recv_channel
 import asyncore, asynchat
@@ -81,7 +82,9 @@
 import stat
 import time
 
+py26_or_later = sys.version_info >= (2,6)
 
+
 class zope_ftp_channel(ftp_channel):
     "Passes its commands to Zope, not a filesystem"
 
@@ -105,14 +108,26 @@
         return path
 
     # Overriden async_chat methods
-
-    def push(self, producer, send=1):
+    def push(self, data, send=1):
         # this is thread-safe when send is false
         # note, that strings are not wrapped in
         # producers by default
-        self.producer_fifo.push(producer)
-        if send: self.initiate_send()
 
+        # LP #418454
+        if py26_or_later:
+            # Python 2.6 or later
+            sabs = self.ac_out_buffer_size
+            if len(data) > sabs:
+                for i in xrange(0, len(data), sabs):
+                    self.producer_fifo.append(data[i:i+sabs])
+            else:
+                self.producer_fifo.append(data)
+        else:
+            # pre-Python 2.6
+            self.producer_fifo.push(data)
+        if send: 
+            self.initiate_send()
+
     push_with_producer=push
 
 



More information about the Zope-Checkins mailing list