[mod_python] How can I have sensible URLs?

Adrien Plisson rien at yeepa.org
Wed Sep 4 18:13:02 EST 2002


From: "Christoph Fritzsch" <christoph at cocon-seide.com>
> But why not seperate them by putting one script in in one file and wrap it
in one def:
> file "input.py" :
>
> def main():
>   all the code input needs
>   return 'the printout'
>
> and call it by http://.../libdb/input/main
> next file "maintainer.py":
> def main():
>  code
>  return 'xx'
> and call it by http://.../libdb/maintainer/main
>
> prerequisite is that the publisher is installed :-)

I was thinking that this was already the case, that's why i didn't precised
it in my previous reply.
so, yes, you can do it this way with the following addenda:

> The only disadvantage would be the trailing /main or whatever you should
call it if main
> is a reseverd word

the trailing main could be added on the server side with a mod_rewrite
RewriteRule, i.e. :
RewriteRule (.*/libd)/([^\.])\.py $1/$2/main
so a client request to:
http://.../libdb/input.py
would be rewriten and will look like:
http://.../libdb/input/main

(the RewriteRule is given in example and has not been tested, so don't
expect it to do the work as it should)

--
rien




More information about the Mod_python mailing list