#18518: wsgi.py does not overwrite DJANGO_SETTINGS_MODULE in apache prefork
-------------------------------+--------------------
     Reporter:  schaefer@…     |      Owner:  nobody
         Type:  Bug            |     Status:  new
    Component:  Uncategorized  |    Version:  1.4
     Severity:  Normal         |   Keywords:
 Triage Stage:  Unreviewed     |  Has patch:  0
Easy pickings:  0              |      UI/UX:  0
-------------------------------+--------------------
 The wsgi.py Django WSGI application shipped with Django 1.4 contains the
 following piece of code:

 {{{
 os.environ.setdefault("DJANGO_SETTINGS_MODULE", "{{ project_name
 }}.settings")
 }}}

 (Obviously adapted to the respective project)

 Using setdefault() here is wrong. When using a preforked Apache, different
 WSGI-application can be run consecutively in the same process. If they use
 different setting modules, the second application will not overwrite the
 settings module of the first, resulting in the wrong Django application to
 be shown.

 == Reproduction ==

 - Create two Django projects
 - Host each of them on a different virtual host
 - Reload one a number of times to "seed" the processes
 - Reload the other one. Notice that (randomly) it shows the *first*
 project instead of the second

 == Fix ==

 Replace the aforementioned line with the following:

 {{{
 os.environ["DJANGO_SETTINGS_MODULE"] = "{{ project_name }}.settings"
 }}}

 There is no reason to try and avoid overwriting the environment variable.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/18518>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to