[mod_python] options to suppress error when accessing module directly with Publisher

Jorey Bump list at joreybump.com
Thu Mar 3 15:14:49 EST 2005


I'm replacing a directory of files with a single module for use with 
Publisher. As this location is used by a new set of users each cycle, I 
won't need to account for any old links. However, it's likely that some 
users will try backing up from the function to the module name itself, 
which will return a mod_python error (I have debug on). Is there any way 
to handle this error in another way?

For example, given a module foo.py with a function bar, this is the link 
we will be distributing to users:

  http://example.com/foo/bar

This also works:

  http://example.com/foo/bar/

And this returns a 404 Not Found error, which is fine:

  http://example.com/foo

But adding a slash returns a mod_python error:

  http://example.com/foo/

This is the kind of thing that users will try to do to search for 
information. It's usually nonmalicious, and some browsers even provide 
convenient widgets to backtrack over an URL. I'd rather return a 404 
than an interpreter error. Any thoughts?

It's interesting that naming a module index.py can hide the module name 
in an URL. Why not do the opposite, and allow a function named index in 
a module to be the default location if the module is called directly, 
with a trailing slash?


More information about the Mod_python mailing list