[mod_python] missing path element in path_info

Matt Goodall matt at pollenation.net
Wed Jul 9 17:35:26 EST 2003


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


More information about the Mod_python mailing list