[Zope3-checkins] SVN: Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/base.py Fixed a bug in handling errors.

Jim Fulton jim at zope.com
Fri Sep 2 19:08:40 EDT 2005


Log message for revision 38272:
  Fixed a bug in handling errors.
  
  Added some test backward compat.
  

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

-=-
Modified: Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/base.py
===================================================================
--- Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/base.py	2005-09-02 22:29:42 UTC (rev 38271)
+++ Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/base.py	2005-09-02 23:08:40 UTC (rev 38272)
@@ -48,8 +48,10 @@
 
     def handleException(self, exc_info):
         'See IPublisherResponse'
+        f = StringIO()
         traceback.print_exception(
-            exc_info[0], exc_info[1], exc_info[2], 100, self)
+            exc_info[0], exc_info[1], exc_info[2], 100, f)
+        self.setResult(f.getvalue())
 
     def internalError(self):
         'See IPublisherResponse'
@@ -214,7 +216,6 @@
 
     publication = property(_getPublication)
 
-
     def processInputs(self):
         'See IPublisherRequest'
         # Nothing to do here
@@ -421,15 +422,27 @@
                 warnings.warn("Can't pass output streams to requests anymore",
                               DeprecationWarning,
                               2)
-                environ = outstream
+                environ, outstream = outstream, environ
                 
         environ['PATH_INFO'] = path
         if body_instream is None:
             body_instream = StringIO('')
 
         super(TestRequest, self).__init__(body_instream, environ)
+        self.response._outstream = outstream
 
+    def _createResponse(self):
+        return BBBResponse()
 
+class BBBResponse(BaseResponse):
+
+    def outputBody(self):
+        import warnings
+        warnings.warn("Can't pass output streams to requests anymore",
+                      DeprecationWarning,
+                      2)
+        self._outstream.write(self.result)
+
 class DefaultPublication(object):
     """A stub publication.
 



More information about the Zope3-Checkins mailing list