[Zope] ZPublisher: How to set the mime header?

Andy Smith andy@ictibroker.com
Tue, 16 Mar 1999 14:40:56 -0500


I've been using this.... (Zope example but should work with ZServer)

It was fully expecting to have to mess about with headers to get browsers to
recognise the gif, but broswers seem to know a gif when they get one!

This example returns gifs in a browser when you do ....

http://mysite/renderGif

or even

<IMG src="renderGif">

(I'm fully prepared to admit there may be better ways of doing it) ;)_

Cheers,

Andy.

    def renderGif(self, size=500, counter=1):
        """Draw a pie chart"""
        im = PIL.Image.new('RGB', (size,size))

        # Do GIF manipulation stuff here!

        outFile = cStringIO.StringIO()
        im.save(outFile, 'GIF')

        outFile.seek(0)
        outString = outFile.read()
        return outString


> -----Original Message-----
> From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of
> Oliver Thuns
> Sent: Tuesday, March 16, 1999 1:44 PM
> To: zope@zope.org
> Subject: [Zope] ZPublisher: How to set the mime header?
>
>
> Hi!
>
> I'm not using zope, but I'm using ZPublisher and ZServer. I'm coding a
> very simple counter module (with PIL). How could I set the mime header
> to image/gif and return an image?
>
>
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://www.zope.org/mailman/listinfo/zope
>
> (For developer-specific issues, use the companion list,
> zope-dev@zope.org - http://www.zope.org/mailman/listinfo/zope-dev )
>