[mod_python] Modpython, Apache, Matplotlib which is responsible

Graham Dumpleton graham.dumpleton at gmail.com
Thu Mar 19 17:31:03 EDT 2009

2009/3/19 Bart <scarfboy at gmail.com>:
> On Thu, Mar 19, 2009 at 4:09 AM, Ron Phelps <rphelps at redshift.com> wrote:
>> Trying to get Apache to display an graph plotfile.png but get an error
>> The website has
>> index.py with links to
>> page1.py
>> page2.py
>> ...
>> pagen.py
>> page1.py calls matplotlib to plot some data retrieved from a database.
>> Matplotlib can't write to the www-data root (permissions problem) so I
>> have it write to /tmp.
>> I then copy the file to the www-data root using pexpect.run('cp
>> plotfile.png').
>> However page1.py fails to display the graph. The error is
>> "can't find /page1.py/plotfile.png."  Page1.py is not a directory
>> The file has the owner:group of www-data.
>> I have verified that the file is in the www-root directory.
>> Don't know if it is an issue but page1.py has two frames. One which is
>> for displaying data.
>> Is Apache or Mod_python the cause?
> You seem to have used SetHandler, to hand over control to mod_python
> unconditionally (for all URLs).
> You also seem to be using mod_python.publisher, which is fine
> (although it's a pain with relative URLs), but which won't fall back
> to serving files, which things like vampire will do.
> IIRC, you can just use AddHandler to handle only .py URLs via
> mod_python (though I'm not sure, I only used publisher briefly and
> it's a good while back now).
> A simpler option may be copying those files to a subdirectory and
> telling apache "SetHandler none" for it, which gets you basic apache
> treatment (in this case for its file serving).
> By the way, you can have matplotlib serve things via memory, avoiding
> the bother of files completely (for most backends, anyway).

The following may be of interest if this relates to SetHandler/AddHandler.



More information about the Mod_python mailing list