[Zope-dev] Optimization and speed

Steve Alexander steve@cat-box.net
Sat, 15 Jul 2000 21:50:10 +0100


Stephan Richter wrote:
> 
> ><snip Method doc string>
> 
> >Looks like it's more that just a tweak, though :-(
> 
> So, how can I use this method? I do not understand the internals of the
> ZServer completely.

You've got a RESPONSE object. For HTTP stuff, it will be a HTTPResponse
as defined in lib/python/ZPublisher/HTTPResponse.py.

You can use the write(self, data) method of this response object to
stream data directly to your client, independent (to a degree) of Zope's
transaction processing.

This is the method from HTTPResponse.

    def write(self,data):
        """\
        Return data as a 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.

        The published object should first set any output headers or
        cookies on the response object.

        Note that published objects must not generate any errors
        after beginning stream-oriented output. 

        """
        if not self._wrote:
            self.outputBody()
            self._wrote=1
            self.stdout.flush()

        self.stdout.write(data)

So, you could set output headers and cookies as needed, then, before the
rest of the processing on your page, have a <dtml-call
"RESPONSE.write('the top of the page')">.

Then again, I've never tried this. YMMV and all that.

(*off to help cook... won't be reading email for a while*)

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net