summaryrefslogtreecommitdiff
path: root/django/contrib/auth/handlers/modpython.py
diff options
context:
space:
mode:
authorRobin Munn <robin.munn@gmail.com>2006-09-25 15:39:20 +0000
committerRobin Munn <robin.munn@gmail.com>2006-09-25 15:39:20 +0000
commit1bb4fa2cb66269b1eff3b7d73f8c7864c0622368 (patch)
tree99ebf72b9983e35e50e65d0d421949a2740bf105 /django/contrib/auth/handlers/modpython.py
parent8afc419b123f315d724cbefdbc4c07f0982627a9 (diff)
sqlalchemy: Merged revisions 3770 to 3831 from trunk.
git-svn-id: http://code.djangoproject.com/svn/django/branches/sqlalchemy@3832 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/contrib/auth/handlers/modpython.py')
-rw-r--r--django/contrib/auth/handlers/modpython.py31
1 files changed, 18 insertions, 13 deletions
diff --git a/django/contrib/auth/handlers/modpython.py b/django/contrib/auth/handlers/modpython.py
index e6719794a1..c7d921313d 100644
--- a/django/contrib/auth/handlers/modpython.py
+++ b/django/contrib/auth/handlers/modpython.py
@@ -22,6 +22,8 @@ def authenhandler(req, **kwargs):
os.environ['DJANGO_SETTINGS_MODULE'] = settings_module
from django.contrib.auth.models import User
+ from django import db
+ db.reset_queries()
# check that the username is valid
kwargs = {'username': req.user, 'is_active': True}
@@ -30,18 +32,21 @@ def authenhandler(req, **kwargs):
if superuser_only:
kwargs['is_superuser'] = True
try:
- user = User.objects.get(**kwargs)
- except User.DoesNotExist:
- return apache.HTTP_UNAUTHORIZED
-
- # check the password and any permission given
- if user.check_password(req.get_basic_auth_pw()):
- if permission_name:
- if user.has_perm(permission_name):
- return apache.OK
+ try:
+ user = User.objects.get(**kwargs)
+ except User.DoesNotExist:
+ return apache.HTTP_UNAUTHORIZED
+
+ # check the password and any permission given
+ if user.check_password(req.get_basic_auth_pw()):
+ if permission_name:
+ if user.has_perm(permission_name):
+ return apache.OK
+ else:
+ return apache.HTTP_UNAUTHORIZED
else:
- return apache.HTTP_UNAUTHORIZED
+ return apache.OK
else:
- return apache.OK
- else:
- return apache.HTTP_UNAUTHORIZED
+ return apache.HTTP_UNAUTHORIZED
+ finally:
+ db.connection.close()