[Zope3-checkins] SVN: Zope3/branches/srichter-twisted-integration2/src/zope/publisher/ Merged in

Stephan Richter srichter at cosmos.phy.tufts.edu
Wed Sep 7 20:57:43 EDT 2005


Log message for revision 38378:
  Merged in
  
  r29989 | srichter | 2005-04-14 15:23:04 -0400 (Thu, 14 Apr 2005) | 3 lines
  
  Switch to using a temporary file. It's better for large amounts of data.
  
  

Changed:
  U   Zope3/branches/srichter-twisted-integration2/src/zope/publisher/http.py
  U   Zope3/branches/srichter-twisted-integration2/src/zope/publisher/tests/test_http.py

-=-
Modified: Zope3/branches/srichter-twisted-integration2/src/zope/publisher/http.py
===================================================================
--- Zope3/branches/srichter-twisted-integration2/src/zope/publisher/http.py	2005-09-08 00:34:11 UTC (rev 38377)
+++ Zope3/branches/srichter-twisted-integration2/src/zope/publisher/http.py	2005-09-08 00:57:42 UTC (rev 38378)
@@ -16,11 +16,11 @@
 $Id$
 """
 import re, time, random
-import cStringIO
 from urllib import quote, unquote, splitport
 from types import StringTypes, ClassType
 from cgi import escape
 from Cookie import SimpleCookie
+from tempfile import TemporaryFile
 
 from zope.deprecation import deprecation
 from zope.interface import implements
@@ -178,7 +178,7 @@
 
     def __init__(self, stream):
         self.stream = stream
-        self.cacheStream = cStringIO.StringIO()
+        self.cacheStream = TemporaryFile()
 
     def getCacheStream(self):
         self.read()

Modified: Zope3/branches/srichter-twisted-integration2/src/zope/publisher/tests/test_http.py
===================================================================
--- Zope3/branches/srichter-twisted-integration2/src/zope/publisher/tests/test_http.py	2005-09-08 00:34:11 UTC (rev 38377)
+++ Zope3/branches/srichter-twisted-integration2/src/zope/publisher/tests/test_http.py	2005-09-08 00:57:42 UTC (rev 38378)
@@ -60,37 +60,42 @@
     def setUp(self):
         self.stream = HTTPInputStream(StringIO(data))
 
+    def getCacheStreamValue(self):
+        self.stream.cacheStream.seek(0)
+        return self.stream.cacheStream.read()
+
     def testRead(self):
         output = ''
-        self.assertEqual(output, self.stream.cacheStream.getvalue())
+        self.assertEqual(output, self.getCacheStreamValue())
         output += self.stream.read(5)
-        self.assertEqual(output, self.stream.cacheStream.getvalue())
+        self.assertEqual(output, self.getCacheStreamValue())
         output += self.stream.read()
-        self.assertEqual(output, self.stream.cacheStream.getvalue())
-        self.assertEqual(data, self.stream.cacheStream.getvalue())
+        self.assertEqual(output, self.getCacheStreamValue())
+        self.assertEqual(data, self.getCacheStreamValue())
 
     def testReadLine(self):
         output = self.stream.readline()
-        self.assertEqual(output, self.stream.cacheStream.getvalue())
+        self.assertEqual(output, self.getCacheStreamValue())
         output += self.stream.readline()
-        self.assertEqual(output, self.stream.cacheStream.getvalue())
+        self.assertEqual(output, self.getCacheStreamValue())
         output += self.stream.readline()
-        self.assertEqual(output, self.stream.cacheStream.getvalue())
+        self.assertEqual(output, self.getCacheStreamValue())
         output += self.stream.readline()
-        self.assertEqual(output, self.stream.cacheStream.getvalue())
-        self.assertEqual(data, self.stream.cacheStream.getvalue())
+        self.assertEqual(output, self.getCacheStreamValue())
+        self.assertEqual(data, self.getCacheStreamValue())
 
     def testReadLines(self):
         output = ''.join(self.stream.readlines(4))
-        self.assertEqual(output, self.stream.cacheStream.getvalue())
+        self.assertEqual(output, self.getCacheStreamValue())
         output += ''.join(self.stream.readlines())
-        self.assertEqual(output, self.stream.cacheStream.getvalue())
-        self.assertEqual(data, self.stream.cacheStream.getvalue())
+        self.assertEqual(output, self.getCacheStreamValue())
+        self.assertEqual(data, self.getCacheStreamValue())
 
     def testGetChacheStream(self):
         self.stream.read(5)
-        self.assertEqual(data, self.stream.getCacheStream().getvalue())
+        self.assertEqual(data, self.stream.getCacheStream().read())
 
+
 class HTTPTests(unittest.TestCase):
 
     _testEnv =  {



More information about the Zope3-Checkins mailing list