Added support to django/contrib/auth/handlers/modpython.py for setting 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
This commit is contained in:
Adrian Holovaty 2006-05-31 02:09:07 +00:00
parent 85ba40f4e2
commit 2f513e0f0e
2 changed files with 14 additions and 2 deletions

View File

@ -10,8 +10,6 @@ def authenhandler(req, **kwargs):
# that so that the following import works # that so that the following import works
os.environ.update(req.subprocess_env) os.environ.update(req.subprocess_env)
from django.contrib.auth.models import User
# check for PythonOptions # check for PythonOptions
_str_to_bool = lambda s: s.lower() in ('1', 'true', 'on', 'yes') _str_to_bool = lambda s: s.lower() in ('1', 'true', 'on', 'yes')
@ -19,6 +17,11 @@ def authenhandler(req, **kwargs):
permission_name = options.get('DjangoPermissionName', None) permission_name = options.get('DjangoPermissionName', None)
staff_only = _str_to_bool(options.get('DjangoRequireStaffStatus', "on")) staff_only = _str_to_bool(options.get('DjangoRequireStaffStatus', "on"))
superuser_only = _str_to_bool(options.get('DjangoRequireSuperuserStatus', "off")) superuser_only = _str_to_bool(options.get('DjangoRequireSuperuserStatus', "off"))
settings_module = options.get('DJANGO_SETTINGS_MODULE', None)
if settings_module:
os.environ['DJANGO_SETTINGS_MODULE'] = settings_module
from django.contrib.auth.models import User
# check that the username is valid # check that the username is valid
kwargs = {'username': req.user, 'is_active': True} kwargs = {'username': req.user, 'is_active': True}

View File

@ -56,6 +56,15 @@ location to users marked as staff members. You can use a set of
required. required.
================================ ========================================= ================================ =========================================
Note that sometimes ``SetEnv`` doesn't play well in this mod_python
configuration, for reasons unknown. If you're having problems getting
mod_python to recognize your ``DJANGO_SETTINGS_MODULE``, you can set it using
``PythonOption`` instead of ``SetEnv``. Therefore, these two Apache directives
are equivalent::
SetEnv DJANGO_SETTINGS_MODULE mysite.settings
PythonOption DJANGO_SETTINGS_MODULE mysite.settings
.. _authentication system: http://www.djangoproject.com/documentation/authentication/ .. _authentication system: http://www.djangoproject.com/documentation/authentication/
.. _Subversion: http://subversion.tigris.org/ .. _Subversion: http://subversion.tigris.org/
.. _mod_dav: http://httpd.apache.org/docs/2.0/mod/mod_dav.html .. _mod_dav: http://httpd.apache.org/docs/2.0/mod/mod_dav.html