[Zope] ChartDirector and Zope
Tino Wildenhain
tino at wildenhain.de
Sat Feb 12 08:52:43 EST 2005
Am Samstag, den 12.02.2005, 08:06 -0500 schrieb Jonathan Hobbs:
> ----- Original Message -----
> From: <hpinson at indepthl.com>
> > Has anyone gotten the (excellent) ChartDirector charting library to
> > work with zope?
> >
> > Here's what I have tried:
> >
> > 1. Created an ExternalMethod named barchart.py, in the Extensions
> > folder:
> > #output the chart
> > print "Content-type: image/png\n"
> > binaryPrint(c.makeChart2(PNG))
>
>
> Where is 'binaryPrint' printing to (a file? stdio?)? I am not familiar
> with ChartDirector, but with PIL we have to trick it to write to a 'ram
> file' and then return that, here are the relevant extracts from an external
> method that uses PIL:
>
> <snip>
> class RamFile:
> def __init__(self):
> self.contents = []
>
> def write(self,s):
> self.contents.append(s)
>
> def read(self):
> return string.join(self.contents,'')
> </snip>
>
> <snip>
> canvas.drawString("S", 7,263, Font(face="times",size=14,bold=1),
> color=black, angle=0)
> canvas.flush()
> rfile = RamFile()
> canvas.save(file=rfile,format="jpeg")
> return rfile.read()
> </snip>
Hm. Wonder why you dont just use cStringIO here?
Tino
More information about the Zope
mailing list