[mod_python] Re: PyChart into web site error

Graham Dumpleton grahamd at dscpl.com.au
Wed Oct 19 18:57:04 EDT 2005


G.M.Dall'Olio wrote ..
> Graham Dumpleton wrote:
> 
> > It isn't mod_python that requires sys.argv, it is pychart that is the
> > problem based
> > on the traceback you provide. Ie., pychart has:
> >
> >   self.title = re.sub("(.*)\\.py$", "\\1", sys.argv[0])
> >
> > In short, pychart is written so as it can only work on the command line.
> >
> 
> Ok, thank you very much!
> I've solved the problem of sys.argv. But then I've found another error.
> 
> The simplest way to fix this sys.argv's problem is to add it on the same
> module, without using PythonImport or similar:
> 
> [python_code]
> import sys
> sys.argv = ['pychart']

There are reasons why setting this here might not be the best idea, but
if it works for you and you are happy, great.

> def plot2():
> 
>         can_obj = StringIO.StringIO()                # create a 
> file-like object with StringIO
>         can = canvas.init(can_obj)                      # this is 
> equivalent to 'sys.stdout = can_obj', so the output will be written in
> can_obj
>         can.set_title('Title1')                                # (By the
> way, this doesn't work in skipping the sys.argv error. See 
> $PythonSitePackages/pychart/basecanvas.py at line 70)

Expected as much.

>         data = [["Jan", 10], ["Feb", 22], ["Mar", 30]]
>         ar = area.T(x_coord = category_coord.T(data, 0),
>         y_range = (0, None),
>         x_axis = axis.X(),
>         y_axis = axis.Y())
>         ar.add_plot(bar_plot.T(data = data, label = "Something"))
> 
>         ar.draw(can)
>         return str(can_obj.read())                       # Try to read
> can_obj. It doesn't work for security problems in Apache. Do I have to
> configure the Directive in a different way?
> [/python_code]

Look in the Apache error log file for what the real error actually is,
or include:

  PythonDebug On

directive in your setup so error is shown to browser.

You will probably find it is just some programming error in your
code.

Graham


More information about the Mod_python mailing list