[mod_python] Newbie question: Apache config

Graham Dumpleton grahamd at dscpl.com.au
Tue Aug 9 18:38:13 EDT 2005


On 10/08/2005, at 7:24 AM, Vijay Avarachen wrote:

> Hello,
>       I am really confused with the way mod_python works.  
> Unfortunately all the examples of apache configuration for mod_python 
> I have seen are not very good, either that or its supposed to be 
> extremely simple and I am not getting it. 

At least for the "mptest.py" example, did you find and read:

   http://www.dscpl.com.au/articles/modpython-001.html

If you did know of this one and thought it wasn't adequate, please
contribute any feedback so it can be made better.

> I have few python scripts that I'd like to run using mod_python, but I 
> can't get them to work using PythonHandler mod_python.publisher.
>
>  Here is what I have in my conf.d/python.conf :
> <Directory "/home/user/public_html/python">
>         AddHandler mod_python .py
>         PythonHandler mod_python.publisher
>         PythonDebug on
> </Directory>
>
>  This does not work for the mptest example from the mod_python 
> documentation.  I don't understand why it does not work.  However 
> changing the line to PythonHandler mptest it works.  I can't imagine 
> having to list out each and every python script I plan to run after 
> PythonHandler.  I know there has to be a better way. 

That configuration will not work properly with mptest.py example code as
the internal way that a Python code file is setup and how your handlers
are defined is somewhat different between mod_python.publisher and a
basic content handler. In mod_python.publisher, it also interprets the
URL in a special way to map requests against the contents of your code
file.

If you did manage to work out the correct URL such that mptest.py did
generate something under mod_python.publisher, you would have found it
probably added the string "0" onto the end of the output wrongly, or the
details of a 500 error generated by Apache may have been appended to the
output in the worst case.

The URL that may have worked for mptest.py under mod_python.publisher
is:

   /~user/python/mptest.py/handler

You should do some more reading into the differences between a basic
content handler and a mod_python.publisher published object and how URL
mapping works in mod_python.publisher.

If all you are after is a way of having different basic content handlers
in distinct files and having the URLs map to each appropriately, you
might also consider looking at Vampire, as it provides this sort of
functionality for mod_python.

   http://www.dscpl.com.au/projects/vampire

Graham



More information about the Mod_python mailing list