Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed a long and complex line by breaking into a for loop, with the a…

…dded 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
  • Loading branch information...
commit 56e1cdc8bc7e5dfeb17178635df2de1e42f790ff 1 parent 73dfef8
Gary Wilson Jr. authored July 02, 2008

Showing 1 changed file with 4 additions and 1 deletion. Show diff stats Hide diff stats

  1. 5  django/contrib/auth/backends.py
5  django/contrib/auth/backends.py
@@ -68,7 +68,10 @@ def has_module_perms(self, user_obj, app_label):
68 68
         """
69 69
         Returns True if user_obj has any permissions in the given app_label.
70 70
         """
71  
-        return bool(len([p for p in self.get_all_permissions(user_obj) if p[:p.index('.')] == app_label]))
  71
+        for perm in self.get_all_permissions(user_obj):
  72
+            if perm[:perm.index('.')] == app_label:
  73
+                return True
  74
+        return False
72 75
 
73 76
     def get_user(self, user_id):
74 77
         try:

0 notes on commit 56e1cdc

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