Sorry about the type (osrc should be isrc). The rationale for this somewhat convoluted approach to displaying images is that the images are in a folder with 'View' permission set to 'Authenticated'. However, in certain conditions I want to allow anonymous users access to some of the images in the folder. Therefore I am using a script/method with proxy set to 'Authenticated' to serve up these images to the public. ----- Original Message ----- From: "Paul Winkler" <pw_lists@slinkp.com> To: <zope@zope.org> Sent: June 2, 2004 1:38 PM Subject: Re: [Zope] Serving up and Image
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
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )