﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
9327	Apache MultiViews, mod_python, and certain URLs result in a 500 error	Carl Meyer	nobody	"If Apache is configured with mod_negotiation and !MultiViews on, a URL like /index may be automatically rewritten to /index.html.  In the course of this internal URL rewrite, the {{{ SetEnv DJANGO_SETTINGS_MODULE }}} directive in a Django/mod_python !VirtualHost appears to be called twice, resulting in a duplicate entry in the mod_python req.subprocess_env table, which is a dict-like object but apparently supports multi-values.  This duplicate entry causes a 500 error when Django's !ModPythonHandler attempts to do {{{ os.environ.update(req.subprocess_env) }}}, with the following traceback in the Apache log:

{{{
File ""/usr/lib/python2.5/site-packages/mod_python/importer.py"", line 1537, in HandlerDispatch
    default=default_handler, arg=req, silent=hlist.silent)
File ""/usr/lib/python2.5/site-packages/mod_python/importer.py"", line 1229, in _process_target
    result = _execute_target(config, req, object, arg)
File ""/usr/lib/python2.5/site-packages/mod_python/importer.py"", line 1128, in _execute_target
    result = object(arg)
File ""/var/www/meyer/lib/py/django/core/handlers/modpython.py"", line 226, in handler
    return ModPythonHandler()(req)
File ""/var/www/meyer/lib/py/django/core/handlers/modpython.py"", line 181, in __call__
    os.environ.update(req.subprocess_env)
File ""/usr/lib/python2.5/os.py"", line 488, in update
    self[k] = dict[k]
File ""/usr/lib/python2.5/os.py"", line 473, in __setitem__
    putenv(key, item)
TypeError: putenv() argument 2 must be string, not list
}}}

(The double-calling of !SetEnv resulting in duplicate entries in subprocess_env is possibly a bug in Apache/mod_python.  In any case it doesn't make much sense to use !MultiViews on an Apache instance serving Django.  Nonetheless, since subprocess_env is a data structure that supports multi-values, and multi-values can occur in it, Django needs to be more careful in calling os.environ.update() this way.)

Reproduced on Apache 2.2.6 (Debian Etch) and 2.2.8 (Ubuntu Hardy) with Django 1.0 and trunk."	Uncategorized	closed	HTTP handling	1.0	Normal	wontfix			Design decision needed	0	0	0	0	0	0
