[mod_python] Re: PyChart into web site error

G.M.Dall'Olio dalloliogm at gmail.com
Wed Oct 19 18:42:38 EDT 2005


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']

def plot2():       

        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"))
        return ar.draw()
[/python_code]

The problem is that this code returns 'None'; because the graph is drawn 
on stdout, and not returned.
So I'm trying to find a way to take stdout in the script, but I receive 
security errors from apache.
For example, there is a module in PyChart called 'canvas' that enable to 
turn the output to a file-like object:

[python_code]
import sys
sys.argv = ['pychart']

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)

        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]

The error returned is this:

----------------
*Internal Server Error*

The server encountered an internal error or misconfiguration and was 
unable to complete your request.

Please contact the server administrator, root at localhost and inform them 
of the time the error occurred, and anything you might have done that 
may have caused the error.

More information about this error may be available in the server error log.

------------------------------------------------------------------------
Apache/2.0.54 (Fedora) Server at localhost Port 80
-----------


So, I don't know how to continue now. By the way, do you know of any 
other module that I can use the generate graphs? I have to generate them 
from a simple list written in xml format. Thank you!




-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20051020/f5ce197d/attachment.html


More information about the Mod_python mailing list