Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added support to django/contrib/auth/handlers/modpython.py for settin…

…g DJANGO_SETTINGS_MODULE via a PythonOption instead of SetEnv

git-svn-id: http://code.djangoproject.com/svn/django/trunk@3012 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 2f513e0f0e95d8f146385803743c7128dbc9b885 1 parent 85ba40f
Adrian Holovaty authored May 31, 2006
7  django/contrib/auth/handlers/modpython.py
@@ -10,8 +10,6 @@ def authenhandler(req, **kwargs):
10 10
     # that so that the following import works
11 11
     os.environ.update(req.subprocess_env)
12 12
 
13  
-    from django.contrib.auth.models import User
14  
-
15 13
     # check for PythonOptions
16 14
     _str_to_bool = lambda s: s.lower() in ('1', 'true', 'on', 'yes')
17 15
 
@@ -19,6 +17,11 @@ def authenhandler(req, **kwargs):
19 17
     permission_name = options.get('DjangoPermissionName', None)
20 18
     staff_only = _str_to_bool(options.get('DjangoRequireStaffStatus', "on"))
21 19
     superuser_only = _str_to_bool(options.get('DjangoRequireSuperuserStatus', "off"))
  20
+    settings_module = options.get('DJANGO_SETTINGS_MODULE', None)
  21
+    if settings_module:
  22
+        os.environ['DJANGO_SETTINGS_MODULE'] = settings_module
  23
+
  24
+    from django.contrib.auth.models import User
22 25
 
23 26
     # check that the username is valid
24 27
     kwargs = {'username': req.user, 'is_active': True}
9  docs/apache_auth.txt
@@ -56,6 +56,15 @@ location to users marked as staff members.  You can use a set of
56 56
                                       required.
57 57
     ================================  =========================================
58 58
 
  59
+Note that sometimes ``SetEnv`` doesn't play well in this mod_python
  60
+configuration, for reasons unknown. If you're having problems getting
  61
+mod_python to recognize your ``DJANGO_SETTINGS_MODULE``, you can set it using
  62
+``PythonOption`` instead of ``SetEnv``. Therefore, these two Apache directives
  63
+are equivalent::
  64
+
  65
+    SetEnv DJANGO_SETTINGS_MODULE mysite.settings
  66
+    PythonOption DJANGO_SETTINGS_MODULE mysite.settings
  67
+
59 68
 .. _authentication system: http://www.djangoproject.com/documentation/authentication/
60 69
 .. _Subversion: http://subversion.tigris.org/
61 70
 .. _mod_dav: http://httpd.apache.org/docs/2.0/mod/mod_dav.html

0 notes on commit 2f513e0

Please sign in to comment.
Something went wrong with that request. Please try again.