[Zope] RESPONSE.Write question

Passin, Tom tpassin at mitretek.org
Tue Sep 16 10:31:29 EDT 2003


[ Small Business Services]

> I have been trying to get a test routine working that uses 
> RESPONSE.write...
> without success:

1) RESPONSE.setHeader() affects the RESPONSE object.  But that does not
mean that anything is actually sent to the browser at that time.  You
need to flush the RESPONSE object (though I do not know if that does
anything before RESPONSE.write() has been invoked).

2) It is invalid to mix non-header material in with the header.  Just
because some browsers handle it gracefully is not a good reason to do
so.

3) Not all browsers will understand chunked data transfer.

If you want to see how long you are waiting for a response, you can
invoke your page by submitting a form, and using javascript, load a page
that only says "Starting..."  When Zope does send its response, it will
overwrite that temporary page.  I have used a similar method - although
I always had the response come up in a second frame, and i am not sure
if this will work if you only have a single frame.  Another approach is
to have your response open in another frame or in a popup window.  Any
of these variations will let you see the start and end of the response.

Cheers,

Tom P

> 
> 
> Here is the dtml code I have been using:
> 
> 
> <dtml-call "RESPONSE.setHeader('Transfer-Encoding', 'chunked')">
> <dtml-call "RESPONSE.setHeader('Content-Type', 'text/plain')">
> <dtml-call "RESPONSE.write('Starting')">
> 
> <dtml-call "wait(5)">
> 
> <dtml-call "RESPONSE.setHeader('Transfer-Encoding', 'chunked')">
> <dtml-call "RESPONSE.setHeader('Content-Type', 'text/plain')">
> <dtml-call "RESPONSE.write('\n\nDone')">
> 
> 
> The 'wait' routine is a simple external method:
> 
> import time
> def wait(self, secs):
>         time.sleep(secs)
>         return
> 
> 
> What I expected to see was the word 'Started' displayed in my browser,
> followed by a 5 second delay, and then see the word 'Done' displayed.
> 
> What I get is a 5 second delay and then both 'Started' and 
> 'Done" appear at
> the same time.
> 
> Any ideas as to what I am doing wrong?
> 



More information about the Zope mailing list