[Zope] Return image from Python Script

Simon Forster simon-lists at ldml.com
Tue Dec 14 11:03:43 EST 2004


On 14 Dec 2004, at 15:55, Jens Vagelpohl 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
>
> That won't work if the file size is large and the data is stored in 
> separate pData structures. You *must* do "return str(image_file.data)" 
> to be on the safe side.

OK. I've added this - but it does seem counter-intuitive to coerce 
binary data to a string before returning it. And more to the point, 
where does one uncover secrets like this?

Simon Forster



More information about the Zope mailing list