modpython handler behaves differently when url matches existing file
|Reported by:||Arthur Hebert||Owned by:||adrian|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
I am migrating my site from PHP to Django, so my public_html directory is full of my old files, such as index.php. Such files are no longer loaded by apache, because they are overridden by /etc/apache2/modules.d/16_mod_python.conf:
... <Directory /space/arthur/public_html/> SetHandler python-program PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE artybear.settings PythonPath "['/home/arthur/projects'] + sys.path" PythonDebug On </Directory> ...
If I request a url that points to the name of a file that exists under the public_html/ directory (not including the file's extension), then I get the following error:
Mod_python error: "PythonHandler django.core.handlers.modpython" Traceback (most recent call last): File "/usr/lib/python2.4/site-packages/mod_python/apache.py", line 299, in HandlerDispatch result = object(req) File "/usr/lib/python2.4/site-packages/django/core/handlers/modpython.py", line 177, in handler return ModPythonHandler()(req) File "/usr/lib/python2.4/site-packages/django/core/handlers/modpython.py", line 137, in __call__ os.environ.update(req.subprocess_env) File "/usr/lib/python2.4/os.py", line 478, in update self[k] = dict[k] File "/usr/lib/python2.4/os.py", line 463, in __setitem__ putenv(key, item) TypeError: putenv() argument 2 must be string, not list
For example, artybear.com/foobar will return the Django debug page, but artybear.com/index will give the error above. If I remove the file index.php from the public_html/ directory, then artybear.com/index will return the Django debug page.
Oddly, artybear.com/index.php will return the Django debug page. The problem only seems to occur when the url points to the basename of a file that Apache would otherwise handle with another program. Some further tests:
$ cd /space/arthur/public_html/ $ $ touch foobar.php # artybear.com/foobar returns error page $ mv foobar.php foobar # artybear.com/foobar returns Django debug page $ mv foobar foobar.txt # artybear.com/foobar returns error page $ mv foobar.txt foobar.foo # artybear.com/foobar returns Django debug page
This is problematic if there's a file called admin.php, because it returns the error page instead of the mapped url (Django's admin page).
I have Django source revision 4193, according to svn update.
Change History (5)
comment:3 Changed 8 years ago by SmileyChris
- Resolution set to worksforme
- Status changed from new to closed
comment:5 Changed 5 years ago by whoisthenirk
- Resolution worksforme deleted
- Status changed from closed to reopened