[Zope3-checkins] SVN: Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/browser.py Added some test backward compat code.

Jim Fulton jim at zope.com
Fri Sep 2 19:37:10 EDT 2005


Log message for revision 38279:
  Added some test backward compat code.
  

Changed:
  U   Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/browser.py

-=-
Modified: Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/browser.py
===================================================================
--- Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/browser.py	2005-09-02 23:37:08 UTC (rev 38278)
+++ Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/browser.py	2005-09-02 23:37:10 UTC (rev 38279)
@@ -610,6 +610,7 @@
             }
 
         if environ:
+            # XXX BBB
             try:
                 _testEnv.update(environ)
             except AttributeError:
@@ -617,7 +618,7 @@
                 warnings.warn("Can't pass output streams to requests anymore",
                               DeprecationWarning,
                               2)
-                environ, form, skin = form, skin, outstream
+                environ, form, skin, outstream = form, skin, outstream, environ
                 _testEnv.update(environ)
                 
         if kw:
@@ -644,11 +645,18 @@
         else:
             directlyProvides(self, IDefaultBrowserLayer)
 
+        self.response.outstream = outstream
+
     def setPrincipal(self, principal):
         # HTTPRequest needs to notify the HTTPTask of the username.
         # We don't want to have to stub HTTPTask in the tests.
         BaseRequest.setPrincipal(self, principal)
 
+    def _createResponse(self):
+        return BBBResponse()
+
+
+
 class BrowserResponse(HTTPResponse):
     """Browser response
     """
@@ -710,6 +718,27 @@
         super(BrowserResponse, self).reset()
         self._base = ''
 
+class BBBResponse(BrowserResponse):
+
+    def testBody(self):
+        return self._body
+    
+    def outputBody(self):
+        import warnings
+        warnings.warn("Can't pass output streams to requests anymore",
+                      DeprecationWarning,
+                      2)
+        self.outstream.write("Status: %s\r\n" % self.getStatusString())
+        headers = self.getHeaders()
+        headers.sort()
+        self.outstream.write(
+            "\r\n".join([("%s: %s" % h) for h in headers])
+            + "\r\n\r\n"
+            )
+        self.outstream.write(''.join(self.result.body))
+    
+
+
 def normalize_lang(lang):
     lang = lang.strip().lower()
     lang = lang.replace('_', '-')



More information about the Zope3-Checkins mailing list