Matt Goodall
matt at pollenation.net
Wed Jul 9 20:36:12 EST 2003
On Wed, 2003-07-09 at 18:10, Gregory (Grisha) Trubetskoy wrote: > I am not sure I understand the difference between the first two, the > request seems to be the same. What are the url's that you're trying to > access (from the browser point of view)? OK, I'm not having a good day ... I can't even copy and paste correctly anymore! The example output should have been as follows, where the browser URL is between the '= =', just above the request attribute list. = /~matt/test/ = the_request: GET /~matt/test/ HTTP/1.1 unparsed_uri: /~matt/test/app.py uri: /~matt/test/app.py filename: /home/matt/public_html/test/app.py path_info: = /~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 example demonstrates that app.py is sometimes part of the filename even when it is not part of the browser's URL. As I mentioned before, it is only example 3 that was a surprise. > > 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. I think this answers the original question anyway. Is there actually a foolproof way of working out the correct base uri of the application (i.e. the path, with or without the app.py) from the information in the request alone? The results I would like are below but I'm not convinced enough information is available: URL app base uri path info ------------------------- ------------------- ---------- /~matt/test/ /~matt/test / /~matt/test/app.py/1/2/3 /~matt/test/app.py /1/2/3 /~matt/test/1/2/3 /~matt/test /1/2/3 Of course, the alternative is for the developer to specify the base uri in configuration code which is how Albatross currently works. Thanks, Matt > > On Wed, 9 Jul 2003, 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 > > _______________________________________________ > > Mod_python mailing list > > Mod_python at modpython.org > > http://mailman.modpython.org/mailman/listinfo/mod_python > > -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenation.net e: matt at pollenation.net
|