[albatross-users] missing path element in path_info
Matt Goodall
matt at pollenation.net
Thu Jul 10 07:35:32 EST 2003
OK, so I got the example output completely wrong (boy, what a day I've
had!) but once I corrected it I got a response from the mod_python list
which I have summarised below.
re: the missing path element in path_info ...
"In the last one, the reason "1" is not part of path_info:
path_info is something apache figures out. I think the rule is
that it sees that "test" is a directory, and the next thing
after it isn't, thus, it must refer to a file (whether or not
the file exists doesn't matter). Everything after a file is
path_info."
re: is there a foolproof way to deduce the correct base url and
path_info ...
"... it is impossible or very difficult to do, because the
transformation from "~matt/test" to
"/home/matt/public_html/test" is not "reversible" and is hidden
somewhere in apache config, yet this mapping is necessary to
produce the results above."
If you're interested in the full thread see
http://www.modpython.org/pipermail/mod_python/2003-July/003420.html.
Cheers, Matt
On Wed, 2003-07-09 at 17:35, Matt Goodall wrote:
> Hi,
>
> Over in the world of Albatross
> (http://www.object-craft.com.au/projects/albatross/) we've been playing
> with path_info and have come across something that we don't quite
> understand.
>
> Here's some example code to demonstrate:
>
> ----- .htaccess -----
> DirectoryIndex app.py
> SetHandler python-program
> PythonHandler app
> -----
>
> ----- app.py -----
> from mod_python import apache
> def handler(req):
> req.content_type = 'text/plain'
> req.send_http_header()
>
> req.write('the_request: %s\n' % req.the_request)
> req.write('unparsed_uri: %s\n' % req.unparsed_uri)
> req.write('uri: %s\n' % req.uri)
> req.write('filename: %s\n' % req.filename)
> req.write('path_info: %s\n' % req.path_info)
>
> return apache.OK
> -----
>
> If I put those files in /~matt/test on the web server then this is what
> I see for each URL:
>
> = URL /~matt/test/1/2/3 =
> the_request: GET /~matt/test/app.py/1/2/3 HTTP/1.1
> unparsed_uri: /~matt/test/app.py/1/2/3
> uri: /~matt/test/app.py/1/2/3
> filename: /home/matt/public_html/test/app.py
> path_info: /1/2/3
>
> = /~matt/test/app.py/1/2/3 =
> the_request: GET /~matt/test/app.py/1/2/3 HTTP/1.1
> unparsed_uri: /~matt/test/app.py/1/2/3
> uri: /~matt/test/app.py/1/2/3
> filename: /home/matt/public_html/test/app.py
> path_info: /1/2/3
>
> = /~matt/test/1/2/3 =
> the_request: GET /~matt/test/1/2/3 HTTP/1.1
> unparsed_uri: /~matt/test/1/2/3
> uri: /~matt/test/1/2/3
> filename: /home/matt/public_html/test/1
> path_info: /2/3
>
> The first two are as expected but the last one drops app.py completely
> and thinks that the first element of path_info is part of the filename.
>
> Can anyone explain this?
>
> Server details:
>
> Apache 1.3.27
> mod_python 2.7.8
> Linux 2.4.x, Gentoo and Debian (I think).
>
> Thanks in advance.
>
> - Matt
--
Matt Goodall, Pollenation Internet Ltd
w: http://www.pollenation.net
e: matt at pollenation.net
t: 0113 2252500
More information about the Albatross-users
mailing list