[Zope] Serving up and Image

Paul Winkler pw_lists at slinkp.com
Wed Jun 2 13:38:56 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?

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

What is osrc?  It's not mentioned elsewhere in this code.
 
I have to wonder why you are doing this, instead of just calling
the object's index_html method, e.g.:

return isrc.index_html(request, RESPONSE)

-- 

Paul Winkler
http://www.slinkp.com



More information about the Zope mailing list