diff options
| author | Anssi Kääriäinen | 2012-08-27 15:29:20 +0300 |
|---|---|---|
| committer | Anssi Kääriäinen | 2012-08-27 15:30:57 +0300 |
| commit | c1f7b3a273600b94dc433902c0a480dc8874d26a (patch) | |
| tree | 88c1f5c775df3be1025bf287b6bcb259e5e26aec /debug_toolbar/utils/tracking/db.py | |
| parent | e806603a6e4ac3d488a0cadb1e962507a6f76fc1 (diff) | |
| download | django-debug-toolbar-c1f7b3a273600b94dc433902c0a480dc8874d26a.tar.bz2 | |
Made usable connections with alias not in db.connections
Diffstat (limited to 'debug_toolbar/utils/tracking/db.py')
| -rw-r--r-- | debug_toolbar/utils/tracking/db.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/debug_toolbar/utils/tracking/db.py b/debug_toolbar/utils/tracking/db.py index 01b4331..2c82920 100644 --- a/debug_toolbar/utils/tracking/db.py +++ b/debug_toolbar/utils/tracking/db.py @@ -88,6 +88,14 @@ class NormalCursorWrapper(object): try: return self.cursor.execute(sql, params) finally: + # FIXME: Sometimes connections which are not in the connections + # dict are used (for example in test database destroying). + # The code below (at least get_transaction_id(alias) needs to have + # the connection in the connections dict. It would be good to + # not have this requirement at all, but for now lets just skip + # these connections. + if self.db.alias not in connections: + return stop = datetime.now() duration = ms_from_timedelta(stop - start) enable_stacktraces = getattr(settings, @@ -119,7 +127,7 @@ class NormalCursorWrapper(object): del cur_frame alias = getattr(self.db, 'alias', 'default') - conn = connections[alias].connection + conn = self.db.connection # HACK: avoid imports if conn: engine = conn.__class__.__module__.split('.', 1)[0] |
