[Zope] Return image from Python Script

Simon Forster simon-lists at ldml.com
Tue Dec 14 12:52:04 EST 2004


On 14 Dec 2004, at 16:46, Florent Guillaume wrote:

>> Thanks. For the record, my final code was:
>>
>> image_file = context.restrictedTraverse('/LDML/images/ldml.gif')
>> context.REQUEST.RESPONSE.setHeader('content-type',
>> image_file.content_type)
>> return image_file.data
>
> The only proper way is:
>
> REQUEST = context.REQUEST
> image_file = context.restrictedTraverse('/LDML/images/ldml.gif')
> return image_file.index_html(REQUEST, REQUEST.RESPONSE)
>
> This sets the headers correctly.
>
> Everything else is a hack.
>
> Florent

Ask 10 people how to do something in Zope - and get 10 different 
answers!

Nothing wrong with hacks. In fact I'd argue that all code is a hack :-) 
Having said this, the example you gave does feel like the correct way 
of doing it. I'll change it forthwith.

Thanks

Simon Forster



More information about the Zope mailing list