summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2010-11-04 00:01:54 +0000
committerAlex Gaynor <alex.gaynor@gmail.com>2010-11-04 00:01:54 +0000
commit877033b479ed4252ed4d40714a70fcb4a85c641f (patch)
tree91d7d77c099663a16b8cf5e7e65ae6fe8e1e0a90
parentd8e311c8d17872162dcb0c43238abd432f124b72 (diff)
Sped up the create_permissions signal handler (and thus the test suite) by restructuring its queries.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14446 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/contrib/auth/management/__init__.py10
1 files changed, 3 insertions, 7 deletions
diff --git a/django/contrib/auth/management/__init__.py b/django/contrib/auth/management/__init__.py
index fe2db75b86..ce93958f0f 100644
--- a/django/contrib/auth/management/__init__.py
+++ b/django/contrib/auth/management/__init__.py
@@ -26,21 +26,17 @@ def create_permissions(app, created_models, verbosity, **kwargs):
searched_perms = set()
# The codenames and ctypes that should exist.
ctypes = set()
- codenames = set()
for klass in app_models:
ctype = ContentType.objects.get_for_model(klass)
ctypes.add(ctype)
for perm in _get_all_permissions(klass._meta):
- codenames.add(perm[0])
searched_perms.add((ctype, perm))
- # Find all the Permissions that a) have a content_type for a model we're
- # looking for, and b) have a codename we're looking for. It doesn't need to
- # have both, we have a list of exactly what we want, and it's faster to
- # write the query with fewer conditions.
+ # Find all the Permissions that have a context_type for a model we're
+ # looking for. We don't need to check for codenames since we already have
+ # a list of the ones we're going to create.
all_perms = set(auth_app.Permission.objects.filter(
content_type__in=ctypes,
- codename__in=codenames
).values_list(
"content_type", "codename"
))