[Zope] Serving up and Image (resolved)

Small Business Services toolkit at magma.ca
Wed Jun 2 16:22:04 EDT 2004


> On Wed, Jun 02, 2004 at 01:19:33PM -0400, Small Business Services wrote:
> > My objective is to serve up an image to the client (browser).
> >
> > I have created a python script with the following code: (I have also
tried
> > dtml and an external method)
> >
> >
> > request = context.REQUEST
> > RESPONSE =  request.RESPONSE
> >
> > isrc = context.restrictedTraverse('Slides/1076436332')
>
> Presumably this is an Image instance?

Yes

>
> > RESPONSE.setHeader('Content-type', 'image/jpeg')
> > RESPONSE.setHeader('Content-length', len(str(isrc)) )
> > RESPONSE.setHeader('Accept-ranges', 'bytes')
> > RESPONSE.setHeader('Last-modified', str(DateTime() )
> > RESPONSE.write(isrc)
> > RESPONSE.flush()

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).







More information about the Zope mailing list