summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGary Wilson Jr <gary.wilson@gmail.com>2008-07-02 05:05:50 +0000
committerGary Wilson Jr <gary.wilson@gmail.com>2008-07-02 05:05:50 +0000
commit56e1cdc8bc7e5dfeb17178635df2de1e42f790ff (patch)
treeb9d7f7fd133a03816b57ba8c47ae307221afd8ca
parent73dfef8771b77ba867d667b2271bb9ee4bec8349 (diff)
Fixed a long and complex line by breaking into a for loop, with the added benefit that the method will now exit as soon as a matching
permission is found instead of checking all of the user's permissions and putting them into a temporary list. git-svn-id: http://code.djangoproject.com/svn/django/trunk@7823 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/contrib/auth/backends.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/django/contrib/auth/backends.py b/django/contrib/auth/backends.py
index 82432e5730..bba883ba78 100644
--- a/django/contrib/auth/backends.py
+++ b/django/contrib/auth/backends.py
@@ -68,7 +68,10 @@ class ModelBackend(object):
"""
Returns True if user_obj has any permissions in the given app_label.
"""
- return bool(len([p for p in self.get_all_permissions(user_obj) if p[:p.index('.')] == app_label]))
+ for perm in self.get_all_permissions(user_obj):
+ if perm[:perm.index('.')] == app_label:
+ return True
+ return False
def get_user(self, user_id):
try: