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

Graham Dumpleton grahamd at dscpl.com.au
Thu Mar 3 16:05:35 EST 2005


Which version of mod_python are you using?

On mod_python-3.1.4 I get OK, OK, 404, 404. I don't get any mod_python 
error
for the last one.

If I add an index() function, then the last two yield the index() 
function
instead as you are expecting.

On 04/03/2005, at 7:14 AM, Jorey Bump wrote:

> 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?
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python



More information about the Mod_python mailing list