[Zope] Serving up and Image

Small Business Services toolkit at magma.ca
Wed Jun 2 13:19:33 EDT 2004


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

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(osrc)
RESPONSE.flush()

return

The HTTP headers I get as a result of this script are:

Status: HTTP/1.1 200 OK
Date: Wed, 02 Jun 2004 17:14:14 GMT
Server: Apache/2.0.40 (Red Hat Linux)
X-Powered-By: Zope (www.zope.org), Python (www.python.org)
Accept-Ranges: bytes
Content-Length: 0
Last-Modified: Thu, 01 Jan 1970 00:00:00 GMT
Connection: close
Content-Type: image/jpeg

Does anyone have any idea why the Content-Length and Last-Modified date are
being reset? (I think the content-length of 0 is the reason this script is
not working - it just displays a broken image icon in the browser window).

All ideas appreciated!

Jonathan








More information about the Zope mailing list