[mod_python] does a mod_python handler exist to generate charts/graphs? (png images)

Gregory (Grisha) Trubetskoy grisha at modpython.org
Mon Sep 22 10:13:56 EST 2003



On Fri, 19 Sep 2003 perry.tew at cibavision.novartis.com wrote:

> I tried to use the StringIO object from both StringIO and cStringIO.
> The library didn't like that at all.  I traced some of the pygdchart
> code.  It drops down into C and calls the following code (from
> _gdchartc.c) ( I stripped out some unnecessary lines):
>
> PyObject *pfile, *labels, *data, *combodata;
> FILE *fp;
> ...
> if (!PyArg_ParseTuple(args, "iiO!iiOiOO", &width, &height, &PyFile_Type,
> &pfile,
> ...
> fp = PyFile_AsFile(pfile);

Since StringIO is not a file (i.e. it is not a Python object of type
"file", it is something else that acts like a file, but only within
Python), I think your only option is to write to a temporary file, then
pass that file in. Take a look at Python's tempfile module (if you haven't
already).

Grisha


More information about the Mod_python mailing list