[mod_python] How to handle multiple .py files using Apache 1.3.x and mod_python 2.7

Jorey Bump list+mod_python at joreybump.com
Thu Apr 15 11:56:34 EST 2004

Eustaquio Rangel de Oliveira Jr. wrote:

> I swear I googled for it for some days but didn't find a good answer to
> it (I found this
> http://www.modpython.org/FAQ/faqw.py?req=show&file=faq01.002.htp but
> only works with Apache2 and mod_python3), so I need to ask you: how can
> I make a config on the httpd.conf to handle all the .py files I could
> have on a directory?
> Maybe I'm missing something on the concept, but let me explain.
> I actually use PHP for web stuff, and have a lot of PHP scripts on some
> dirs.
> Let's suppose I have 100 .php, if I have 100 .py and need to configure
> httpd.conf to handle it and restart Apache everytime I make a .py will
> be very hard to deal with this, so I just need something like "hey,
> execute that .py there" stuff.
> Is there a way to do that? I didn't find a clear answer to this yet. Or
> as I said, maybe I'm missing the concept of how things works with
> mod_python.

Assuming you're using publisher and your DocumentRoot is /var/www/html, 
you can do this:

  <Directory /var/www/html>
    AddHandler python-program .py
    PythonHandler mod_python.publisher
    PythonDebug On

That would allow you to use .py files almost anywhere. Specify a 
subdirectory if you want to limit it. There are no conflicts with mod_php.

More information about the Mod_python mailing list