[Zope-Checkins] CVS: Zope/lib/python/ZServer - HTTPResponse.py:1.43.8.1.4.1

Chris McDonough chrism at plope.com
Sun Mar 21 14:39:23 EST 2004


Update of /cvs-repository/Zope/lib/python/ZServer
In directory cvs.zope.org:/tmp/cvs-serv11574

Modified Files:
      Tag: chrism-publishfile-branch
	HTTPResponse.py 
Log Message:
Initial stab at being able to return producer objects from Zope code instead of strings (to allow the serving of file-like objects to be faster).


=== Zope/lib/python/ZServer/HTTPResponse.py 1.43.8.1 => 1.43.8.1.4.1 ===
--- Zope/lib/python/ZServer/HTTPResponse.py:1.43.8.1	Thu Jan  8 18:34:02 2004
+++ Zope/lib/python/ZServer/HTTPResponse.py	Sun Mar 21 14:38:52 2004
@@ -49,6 +49,7 @@
     _streaming=0
     # using chunking transfer-encoding
     _chunking=0
+    _bodyproducer = None
 
     def __str__(self,
                 html_search=re.compile('<html>',re.I).search,
@@ -230,6 +231,17 @@
         self._retried_response = response
         return response
 
+    def outputBody(self):
+        """Output the response body"""
+        self.stdout.write(str(self))
+        if self._bodyproducer:
+            self.stdout.write(self._bodyproducer, 0)
+
+    def setBodyProducer(self, producer):
+        assert(self.headers.has_key('content-length'))
+        assert(hasattr(producer, 'more'))
+        self._bodyproducer = producer
+        return self
 
 class ChannelPipe:
     """Experimental pipe from ZPublisher to a ZServer Channel.




More information about the Zope-Checkins mailing list