Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Sped up the create_permissions signal handler (and thus the test suit…

…e) by restructuring its queries.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@14446 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 877033b479ed4252ed4d40714a70fcb4a85c641f 1 parent d8e311c
Alex Gaynor authored November 04, 2010
10  django/contrib/auth/management/__init__.py
@@ -26,21 +26,17 @@ def create_permissions(app, created_models, verbosity, **kwargs):
26 26
     searched_perms = set()
27 27
     # The codenames and ctypes that should exist.
28 28
     ctypes = set()
29  
-    codenames = set()
30 29
     for klass in app_models:
31 30
         ctype = ContentType.objects.get_for_model(klass)
32 31
         ctypes.add(ctype)
33 32
         for perm in _get_all_permissions(klass._meta):
34  
-            codenames.add(perm[0])
35 33
             searched_perms.add((ctype, perm))
36 34
 
37  
-    # Find all the Permissions that a) have a content_type for a model we're
38  
-    # looking for, and b) have a codename we're looking for. It doesn't need to
39  
-    # have both, we have a list of exactly what we want, and it's faster to
40  
-    # write the query with fewer conditions.
  35
+    # Find all the Permissions that have a context_type for a model we're
  36
+    # looking for.  We don't need to check for codenames since we already have
  37
+    # a list of the ones we're going to create.
41 38
     all_perms = set(auth_app.Permission.objects.filter(
42 39
         content_type__in=ctypes,
43  
-        codename__in=codenames
44 40
     ).values_list(
45 41
         "content_type", "codename"
46 42
     ))

0 notes on commit 877033b

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