summaryrefslogtreecommitdiff
path: root/django/contrib/contenttypes
diff options
context:
space:
mode:
authorJacob Kaplan-Moss <jacob@jacobian.org>2008-08-06 15:32:46 +0000
committerJacob Kaplan-Moss <jacob@jacobian.org>2008-08-06 15:32:46 +0000
commit34a3bd52255a2253696b74b2d76133aace839fd2 (patch)
tree73bc39cc2e0a93925b1e8796b18224192e19e4a3 /django/contrib/contenttypes
parentd06b474251c979c512a966a7fb41cd8a06487c14 (diff)
Major refactoring of django.dispatch with an eye towards speed. The net result is that signals are up to 90% faster.
Though some attempts and backwards-compatibility were made, speed trumped compatibility. Thus, as usual, check BackwardsIncompatibleChanges for the complete list of backwards-incompatible changes. Thanks to Jeremy Dunck and Keith Busell for the bulk of the work; some ideas from Brian Herring's previous work (refs #4561) were incorporated. Documentation is, sigh, still forthcoming. Fixes #6814 and #3951 (with the new dispatch_uid argument to connect). git-svn-id: http://code.djangoproject.com/svn/django/trunk@8223 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/contrib/contenttypes')
-rw-r--r--django/contrib/contenttypes/generic.py5
-rw-r--r--django/contrib/contenttypes/management.py5
2 files changed, 4 insertions, 6 deletions
diff --git a/django/contrib/contenttypes/generic.py b/django/contrib/contenttypes/generic.py
index 2d38936265..3d1980a982 100644
--- a/django/contrib/contenttypes/generic.py
+++ b/django/contrib/contenttypes/generic.py
@@ -8,7 +8,6 @@ from django.db import connection
from django.db.models import signals
from django.db.models.fields.related import RelatedField, Field, ManyToManyRel
from django.db.models.loading import get_model
-from django.dispatch import dispatcher
from django.utils.functional import curry
class GenericForeignKey(object):
@@ -29,12 +28,12 @@ class GenericForeignKey(object):
self.cache_attr = "_%s_cache" % name
# For some reason I don't totally understand, using weakrefs here doesn't work.
- dispatcher.connect(self.instance_pre_init, signal=signals.pre_init, sender=cls, weak=False)
+ signals.pre_init.connect(self.instance_pre_init, sender=cls, weak=False)
# Connect myself as the descriptor for this field
setattr(cls, name, self)
- def instance_pre_init(self, signal, sender, args, kwargs):
+ def instance_pre_init(self, signal, sender, args, kwargs, **_kwargs):
"""
Handles initializing an object with the generic FK instaed of
content-type/object-id fields.
diff --git a/django/contrib/contenttypes/management.py b/django/contrib/contenttypes/management.py
index 49083d6d5c..736e213665 100644
--- a/django/contrib/contenttypes/management.py
+++ b/django/contrib/contenttypes/management.py
@@ -1,9 +1,8 @@
from django.contrib.contenttypes.models import ContentType
-from django.dispatch import dispatcher
from django.db.models import get_apps, get_models, signals
from django.utils.encoding import smart_unicode
-def update_contenttypes(app, created_models, verbosity=2):
+def update_contenttypes(app, created_models, verbosity=2, **kwargs):
"""
Creates content types for models in the given app, removing any model
entries that no longer have a matching model class.
@@ -37,7 +36,7 @@ def update_all_contenttypes(verbosity=2):
for app in get_apps():
update_contenttypes(app, None, verbosity)
-dispatcher.connect(update_contenttypes, signal=signals.post_syncdb)
+signals.post_syncdb.connect(update_contenttypes)
if __name__ == "__main__":
update_all_contenttypes()