[Zope-Checkins] SVN: Zope/branches/tseaver-fix_wsgi/src/ZPublisher/WSGIPublisher.py Override the 'write' method to avoid the stringification.

Tres Seaver tseaver at palladion.com
Sat May 29 16:52:09 EDT 2010


Log message for revision 112844:
  Override the 'write' method to avoid the stringification.
  
  This should allow things like the Plone resource registry to work properly.

Changed:
  U   Zope/branches/tseaver-fix_wsgi/src/ZPublisher/WSGIPublisher.py

-=-
Modified: Zope/branches/tseaver-fix_wsgi/src/ZPublisher/WSGIPublisher.py
===================================================================
--- Zope/branches/tseaver-fix_wsgi/src/ZPublisher/WSGIPublisher.py	2010-05-29 19:20:16 UTC (rev 112843)
+++ Zope/branches/tseaver-fix_wsgi/src/ZPublisher/WSGIPublisher.py	2010-05-29 20:52:08 UTC (rev 112844)
@@ -18,11 +18,12 @@
 from zExceptions import Redirect
 from zExceptions import Unauthorized
 from ZServer.medusa.http_date import build_http_date
+from zope.event import notify
 
-
 from ZPublisher.HTTPResponse import HTTPResponse
 from ZPublisher.HTTPRequest import HTTPRequest
 from ZPublisher.mapply import mapply
+from ZPublisher.pubevents import PubBeforeStreaming
 from ZPublisher.Publish import call_object
 from ZPublisher.Publish import dont_publish_class
 from ZPublisher.Publish import get_module_info
@@ -102,6 +103,22 @@
     def _unauthorized(self):
         self.setStatus(401)
 
+    def write(self,data):
+        """ Add data to our output stream.
+
+        HTML data may be returned using a stream-oriented interface.
+        This allows the browser to display partial results while
+        computation of a response to proceed.
+        """
+        if not self._streaming:
+            
+            notify(PubBeforeStreaming(self))
+            
+            self._streaming = 1
+            self.stdout.flush()
+
+        self.stdout.write(data)
+
     def setBody(self, body, title='', is_error=0):
         if isinstance(body, file):
             body.seek(0, 2)



More information about the Zope-Checkins mailing list