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

Moore, Paul Paul.Moore at atosorigin.com
Mon Jun 7 13:52:34 EDT 2004


Gregory (Grisha) Trubetskoy wrote:

> 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.

In my case, the problem is that I *am* using an alias. The background
is that MoinMoin includes mod_python support now. However, MoinMoin
URLs are of the form

    http://server.name/wiki/PageName

Here, "wiki" is an alias set up to point to the MoinMoin instance
directory, and PageName is the name of the page to display. In order
for the MoinMoin code to figure out the page, it needs to be able to
split the URL up into the "script" (/wiki) and the "path" (/PageName).
I suspect that this is because the original version of MoinMoin used
CGI, so the "script" was /whatever/path/you/want/moin.cgi and the path
can come from the standard CGI PATH_INFO variable.

Actually, I think I have a solution. Rather than using a Directory, I
can just use a Location. If I do that, the path_info attribute is
"correct" (ie, it includes everything after the part of the URL which
names the location).

So I have

<Location /wiki>
    # Use mod_python as handler
    SetHandler python-program

    # set the path to the MoinMoin package and to the moin_config.py
    PythonPath "['D:/Moin/dbawiki']+sys.path"

    # choose the ModPy Request class as handler
    PythonHandler MoinMoin.request::RequestModPy.run
</Location>

This seems to work as required. (I'm not 100% sure why, as MoinMoin
seems to be using SCRIPT_PATH, which is empty, but hey, if it works...

Paul.


__________________________________________________________________________
This e-mail and the documents attached are confidential and intended 
solely for the addressee; it may also be privileged. If you receive this 
e-mail in error, please notify the sender immediately and destroy it.
As its integrity cannot be secured on the Internet, the Atos Origin group 
liability cannot be triggered for the message content. Although the 
sender endeavours to maintain a computer virus-free network, the sender 
does not warrant that this transmission is virus-free and will not be 
liable for any damages resulting from any virus transmitted.
__________________________________________________________________________



More information about the Mod_python mailing list