[Zope] Serving up and Image (resolved)

Paul Winkler pw_lists at slinkp.com
Wed Jun 2 16:34:24 EDT 2004


On Wed, Jun 02, 2004 at 04:22:04PM -0400, Small Business Services wrote:
> After some investigation it turns out the server was closing the connection
> before all the data was written.  The solution was:
> 
> RESPONSE.write(str(isrc))
> 
> Which created an http-friendly data stream (apparently something in the jpg
> data stream caused the problem).

or maybe RESPONSE.write(isrc) was implicitly doing repr(isrc)
instead of str(isrc).  not sure.

In any case, I'd again suggest calling 
isrc.index_html(request, RESPONSE).
It scales much better to large images.

Your method will read the entire image data into memory as a string
and not return anything to the client until it is done.
Image.index_html() will stream the data in chunks as they are loaded
from the ZODB.  This uses less memory and is faster.

-- 

Paul Winkler
http://www.slinkp.com



More information about the Zope mailing list