[mod_python] how to define publisher when page not found

Graham Dumpleton grahamd at dscpl.com.au
Mon Jan 15 16:17:12 EST 2007


Maksim Kasimov wrote ..
> hi,
> 
> in apache conf file i use:
> 
>     <Directory "/mypath/mydir">
>         SetHandler python-program
>         PythonHandler mod_python.publisher
>     </Directory>
> 
> 
> there is file:
> 
> in file  /mypath/mydir/index.py there some functions:
> 
> def index(req):
> 
>     return "index"
> 
> 
> def free(req):
> 
>     return 'free'
> 
> 
> def not_found(req):
> 
>     # some computation
>     return 'page not found'
> 
> 
> 
> and every thing is just fine and works as expected:
> 
>        for http://myhostname.org/mydir/free i can see "free"
>        for http://myhostname.org/mydir/ i can see "index"
> 
> 
> my question is: How to get output of "not_found" function for any other
> uri,
> such as "http://myhostname.org/mydir/hello" ?
> 
> many thanks for any advice.

Use the Apache ErrorDocument directive, specifying the URL to the not_found
function as the argument.

Graham


More information about the Mod_python mailing list