From: "Stephen Rudd" <stephen.rudd@btk.utu.fi>
Please excuse another dumb question. I wish to produce some dynamic graphs inside Zope to display biological data. I am using pychart, this is clean and IMO has the best looking output for least amount of effort. I can produce graphics by writing a .png file to disk, and then reading it back to return to the client as RESPONSE. This is not optimal - why do I bother writing something to disk, to read it again to delete it?
I have had a play using cStringIO, but cannot make this work. Does anyone have any pointers or examples of how I can create graphics in PyChart and display them using Zope without needing to write binary intermediates to the filesystem?
I use cStringIO, but with a graphics package called 'gdchart'. Here are a few relevant code bits:
From the calling routine (a dtml method):
<dtml-let agraph="graphics(graphtype)"> ... do something with 'agraph' The external method ('graphics.py'): import gdchart import cStringIO # optional from chart import Chart class TestChart(Chart): def __init__(self): Chart.__init__(self) def draw(self, style, size, file, labels, *data): Chart.draw(self) args = (style, size, file, labels) + data apply(gdchart.chart, args) def graphics(gtype): c = TestChart() rfile = cStringIO.StringIO() c.draw(gdchart.GDC_BAR, size, rfile, days, datalist) return rfile HTH Jonathan