[Zope] Return image from Python Script

Florent Guillaume fg at nuxeo.com
Tue Dec 14 11:46:35 EST 2004


> 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

-- 
Florent Guillaume, Nuxeo (Paris, France)   CTO, Director of R&D
+33 1 40 33 71 59   http://nuxeo.com   fg at nuxeo.com


More information about the Zope mailing list