[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/ftp/ Fixed bug #532 in collector.

Michael Kerrin michael.kerrin at openapp.biz
Fri Jan 20 15:35:31 EST 2006


Log message for revision 41390:
  Fixed bug #532 in collector.
  

Changed:
  U   Zope3/trunk/src/zope/app/ftp/__init__.py
  U   Zope3/trunk/src/zope/app/ftp/tests/test_ftpview.py

-=-
Modified: Zope3/trunk/src/zope/app/ftp/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/ftp/__init__.py	2006-01-20 19:53:57 UTC (rev 41389)
+++ Zope3/trunk/src/zope/app/ftp/__init__.py	2006-01-20 20:35:30 UTC (rev 41390)
@@ -114,6 +114,10 @@
         if start:
             data = data[start:]
 
+        ## Some output streams don't support unicode data.
+        if isinstance(data, unicode):
+            data = data.encode('utf-8')
+
         outstream.write(data)
 
     def lsinfo(self, name=None):

Modified: Zope3/trunk/src/zope/app/ftp/tests/test_ftpview.py
===================================================================
--- Zope3/trunk/src/zope/app/ftp/tests/test_ftpview.py	2006-01-20 19:53:57 UTC (rev 41389)
+++ Zope3/trunk/src/zope/app/ftp/tests/test_ftpview.py	2006-01-20 20:35:30 UTC (rev 41390)
@@ -109,6 +109,16 @@
     d.update(info)
     return d
 
+class UnicodeStringIO(StringIO):
+    # We can't write unicode data directly to a socket stream so make sure
+    # that none of the tests below those this.
+    
+    def write(self, str):
+        if isinstance(str, unicode):
+            raise TypeError, "Data must not be unicode"
+        return StringIO.write(self, str)
+
+
 class Test(PlacelessSetup, TestCase):
 
     def setUp(self):
@@ -120,7 +130,7 @@
         defineChecker(File, filechecker)
         defineChecker(Directory, dirchecker)
 
-        root = Directory()
+        root = self.root = Directory()
         root['test'] = Directory()
         root['test2'] = Directory()
         root['f'] = File('contents of\nf')
@@ -273,6 +283,16 @@
         self.assert_(not self.__view.readable('notthere'))
         self.assert_(self.__view.readable('test'))
 
+    def test_read_unicode(self):
+        root = self.root
+        root['uf'] = File(u'unicode contents of\nuf')
+        f = UnicodeStringIO()
+        self.__view.readfile('uf', f)
+        ## the value of f a non-unicode value - since it got encoded in the
+        ## readfile method.
+        self.assertEqual(f.getvalue(), 'unicode contents of\nuf')
+
+
 def test_suite():
     return TestSuite((
         makeSuite(Test),



More information about the Zope3-Checkins mailing list