[mod_python] How do I split up the URI in a request handler?

Gregory (Grisha) Trubetskoy grisha at modpython.org
Sun Jun 6 20:35:59 EDT 2004


The answer to this is not as simple as it would seem it should be, because
"/mywebdir" could be a directory such that DocumentRoot + "/mywedir" would
give you the path on disk, but it could also be an alias, in which case
there is no way to know what directory you're in...

But assuming you don't use aliases, req.filename will tell you what
directory you're in.

Also you may want to take a look at the publisher.py code, it deals with
that same issue.

Grisha

On Sun, 6 Jun 2004, Paul Moore wrote:

> In section 3.3 of the manual, at the end ("Some food for thought"), it
> points out that the name of the Python file in the URL
> http://myserver/mywebdir/myscript.py is not relevant to what Python
> function gets called. I understand that, and I see that the handler
> needs to parse the URL in order to get access to the filename
> "myscript.py" should I require it for any reason.
>
> The req.uri attribute gives me "/mywebdir/myscript.py". But how do I
> find that my handler is being called "from" /mywebdir, to know how
> much of the URI to strip off the front?
>
> It seems to me that this is a pretty basic requirement for URI
> parsing, so I'm assuming that I am missing something straightforward.
> But for the life of me, I can't see it :-( This is causing a problem
> for me in the mod_python support in MoinMoin, so I'd appreciate any
> pointers.
>
> Thanks,
> Paul.
> --
> This signature intentionally left blank
>
> _______________________________________________
> 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