summaryrefslogtreecommitdiff
path: root/django/db/__init__.py
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/db/__init__.py
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/db/__init__.py')
-rw-r--r--django/db/__init__.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/django/db/__init__.py b/django/db/__init__.py
index 95dd36822e..37c8837b8b 100644
--- a/django/db/__init__.py
+++ b/django/db/__init__.py
@@ -2,7 +2,6 @@ import os
from django.conf import settings
from django.core import signals
from django.core.exceptions import ImproperlyConfigured
-from django.dispatch import dispatcher
from django.utils.functional import curry
__all__ = ('backend', 'connection', 'DatabaseError', 'IntegrityError')
@@ -58,17 +57,19 @@ IntegrityError = backend.IntegrityError
# Register an event that closes the database connection
# when a Django request is finished.
-dispatcher.connect(connection.close, signal=signals.request_finished)
+def close_connection(**kwargs):
+ connection.close()
+signals.request_finished.connect(close_connection)
# Register an event that resets connection.queries
# when a Django request is started.
-def reset_queries():
+def reset_queries(**kwargs):
connection.queries = []
-dispatcher.connect(reset_queries, signal=signals.request_started)
+signals.request_started.connect(reset_queries)
# Register an event that rolls back the connection
# when a Django request has an exception.
-def _rollback_on_exception():
+def _rollback_on_exception(**kwargs):
from django.db import transaction
transaction.rollback_unless_managed()
-dispatcher.connect(_rollback_on_exception, signal=signals.got_request_exception)
+signals.got_request_exception.connect(_rollback_on_exception)