Apache Mod-Python - Problem with req.path_info

This is Interesting: Free IT Magazines  
Home > Archive > Apache Mod-Python > August 2005 > Problem with req.path_info





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Problem with req.path_info
Erik Demaine

2005-08-23, 5:46 pm

[As far as I can tell, this is the place to send bugs.
Apologies if this is not correct.]

Dear Developers,

I find that req.path_info is in some cases set to None instead of a string
such as ''. My reading of the documentation suggests that req.path_info
should always be a string.

In particular, req.path_info being None causes a crash in cgihandler.
Lines 541--544 of mod_python/apache.py say

if len(req.path_info) > 0:
env["SCRIPT_NAME"] = req.uri[:-len(req.path_info)]
else:
env["SCRIPT_NAME"] = req.uri

which fails on the first line (the len call) if req.path_info is None.


Circumstance in which req.path_info is set to None:
Apache .htaccess includes
DirectoryIndex index.html index.py index.cgi
The script is called index.py.
The URI does not mention the script name, just the directory name, as in
http://www.foo.com/directory_containing_index.py/

(On the other hand, the URI
http://www.foo.com/directory_with_index.py/index.py
works fine, setting req.path_info to '' as it should.)


Let me know if you need further details.

Erik
Graham Dumpleton

2005-08-23, 5:46 pm

Erik Demaine wrote ..
> [As far as I can tell, this is the place to send bugs.
> Apologies if this is not correct.]
>
> Dear Developers,
>
> I find that req.path_info is in some cases set to None instead of a string
> such as ''. My reading of the documentation suggests that req.path_info
> should always be a string.


Should read, will be string if set, otherwise None. There are a other
members of the request object which are similar, eg, req.finfo, where
the values can also be None as well as the indicated type.

In effect it just passes through what Apache sets it to, in the
circumstances you indicate, it is Apache that is leaving the value as a
null pointer and mod_python is simply propogating that.

> In particular, req.path_info being None causes a crash in cgihandler.
> Lines 541--544 of mod_python/apache.py say
>
> if len(req.path_info) > 0:
> env["SCRIPT_NAME"] = req.uri[:-len(req.path_info)]
> else:
> env["SCRIPT_NAME"] = req.uri
>
> which fails on the first line (the len call) if req.path_info is None.


Yes, it would appear that it needs fixing. Unless one of the developers
does it before you, you can log a bug report at:

http://issues.apache.org/jira/brows...N?report=select

> Circumstance in which req.path_info is set to None:
> Apache .htaccess includes
> DirectoryIndex index.html index.py index.cgi
> The script is called index.py.
> The URI does not mention the script name, just the directory name, as in
> http://www.foo.com/directory_containing_index.py/
>
> (On the other hand, the URI
> http://www.foo.com/directory_with_index.py/index.py
> works fine, setting req.path_info to '' as it should.)
>
>
> Let me know if you need further details.
>
> Erik
> --
> Erik Demaine | edemaine@mit.edu | http://theory.csail.mit.edu/~edemaine/


Graham Dumpleton

2005-08-23, 5:46 pm

Hmmm, I should check code first. This is already rectified in latest subversion
copy of source code:

if req.path_info and len(req.path_info) > 0:
env["SCRIPT_NAME"] = req.uri[:-len(req.path_info)]
else:
env["SCRIPT_NAME"] = req.uri

No need to log a bug report. It will be fixed in 3. anyway.

Graham Dumpleton wrote ..[vbcol=seagreen]
> Erik Demaine wrote ..
>
> Should read, will be string if set, otherwise None. There are a other
> members of the request object which are similar, eg, req.finfo, where
> the values can also be None as well as the indicated type.
>
> In effect it just passes through what Apache sets it to, in the
> circumstances you indicate, it is Apache that is leaving the value as a
> null pointer and mod_python is simply propogating that.
>
>
> Yes, it would appear that it needs fixing. Unless one of the developers
> does it before you, you can log a bug report at:
>
> http://issues.apache.org/jira/brows...N?report=select
>
> in

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com