Graham Dumpleton
grahamd at dscpl.com.au
Fri Oct 14 17:58:46 EDT 2005
On 14/10/2005, at 10:13 PM, <python_it at hotmail.com> wrote: > Did somebody has experience with CharDirector and Mod_python > (Publisher). > (Python 2.4 / ChartDirector for Python / Modpython 3.2.2b) > I can’t make chart with this combination? (I don’t get errors?) > Publisher is working ok with other scripts. > > I use the following script files: > > Index.htm => index.py => chart.tmpl > > Index.htm > ================= > Link to index.py > > > Index.py > ================= > from mod_python import psp,util > > def index(req, perc=[10 , 10 , 80], descrip=['10', '10' ,'80'], > title="chart", filename="chart.png"): > req.content_type = ‘text/html’ > tmpl = psp.PSP(req, filename='templates/chart.tmpl', vars= > {'req': req, 'psp': psp, 'perc': perc, 'descrip': descrip, 'title': > title, 'filename': filename}) > tmpl.run() For the filename argument you are using a relative pathname. This will not work as Apache often runs with cwd as '/' or some other directory. It will not be the directory the script file is in and changing cwd should not be done. Instead use: import os __here__ = os.path.dirname(__file__) from mod_python import psp,util def index(req, perc=[10 , 10 , 80], descrip=['10', '10' ,'80'], title="chart", filename="chart.png"): req.content_type = ‘text/html’ filename = os.path.join(__here__,'templates/chart.tmpl') tmpl = psp.PSP(req, filename=filename vars={'req': req, 'psp': psp, 'perc': perc,'descrip': descrip, 'title': title, 'filename': filename}) tmpl.run()
|