[mod_python] questions about mod_python publisher

Terry MacDonald terry.macdonald at dsl.pipex.com
Thu May 20 01:14:49 EDT 2004

On Wed, 2004-05-19 at 19:40, Volodya wrote:

> Just write your publisher's code into index.py file.
> For example , if we have /var/www/test/index.py (where /var/www/ is
> the httpd's document root), than we can use:
> http://SERVER/test/     	(calls index function in index.py)
> http://SERVER/test/hello        (calls hello function in index.py)
> http://SERVER/test/?id=555      (calls index function with id paramater
> 				set to 555)
> Set these options for test subdirectory (as for me, i prefer .htaccess):
>   SetHandler mod_python
>   PythonHandler mod_python.publisher

If I use SetHandler 

 http://SERVER/test/ causes a forbidden error
 http://SERVER/test/hello causes a not found error

Using Addhandler works but with a minor error explained in a mail I
posted back on the 12 May and repeated below...

Here is my current apache config for mod_python:
PythonDebug on
PythonOption SessionDbm /tmp/app_sess.dbm
Alias /python/ "/var/www/python/"
<Directory "/var/www/python">
    PythonPath "['/var/www/python']+sys.path"
    AddHandler mod_python .py
    PythonHandler mod_python.publisher
    Options None
    AllowOverride None
    Order allow,deny
    Allow from all
Alias /app/ "/var/www/python/app/"
                                                                                                                  <Directory "/var/www/python/app">
    PythonPath ['/var/www/python/app']+sys.path
    DirectoryIndex league.py
<Directory "/var/www/python/app/members">
    PythonOption ApplicationPath /app/members
    PythonAuthenHandler authenticate
    AuthType Basic
    AuthName "Administration"
    Require valid-user

If my league.py file/module contains a function called index() and
another function called hello() then...

http://localhost/app/league.py successfully calls index()
http://localhost/app/ successfully calls index()
http://localhost/app/league.py/hello successfully calls hello()
http://localhost/app/hello causes a not found error on URL /app/hello

The last one contradicts what is described in section ' -
Traversal' of the mod_python manual.

Is this a bug, or is the apache config wrong?

Note: This is also the case if the league.py file is renamed to
index.py.  However, if I do that then http://app/ causes a forbidden

Registered Linux User # 311806

More information about the Mod_python mailing list