[Zope3-checkins] SVN: Zope3/branches/3.2/src/zope/app/ftp/ Merged from trunk.

Michael Kerrin michael.kerrin at openapp.biz
Fri Jan 20 16:49:12 EST 2006


Log message for revision 41391:
  Merged from trunk.
  
  ------------------------------------------------------------------------
  r41390 | mkerrin | 2006-01-20 20:35:30 +0000 (Fri, 20 Jan 2006) | 2 lines
  
  Fixed bug #532 in collector.
  

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

-=-
Modified: Zope3/branches/3.2/src/zope/app/ftp/__init__.py
===================================================================
--- Zope3/branches/3.2/src/zope/app/ftp/__init__.py	2006-01-20 20:35:30 UTC (rev 41390)
+++ Zope3/branches/3.2/src/zope/app/ftp/__init__.py	2006-01-20 21:49:12 UTC (rev 41391)
@@ -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/branches/3.2/src/zope/app/ftp/tests/test_ftpview.py
===================================================================
--- Zope3/branches/3.2/src/zope/app/ftp/tests/test_ftpview.py	2006-01-20 20:35:30 UTC (rev 41390)
+++ Zope3/branches/3.2/src/zope/app/ftp/tests/test_ftpview.py	2006-01-20 21:49:12 UTC (rev 41391)
@@ -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