summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArmin Ronacher <armin.ronacher@active-4.com>2016-04-22 23:38:57 +0200
committerArmin Ronacher <armin.ronacher@active-4.com>2016-04-22 23:47:17 +0200
commit9416b79979ecce1aa2c0b18930a9fd87cd7f0432 (patch)
treeda16c867bace9e001e4966a997c4ff9ec1b7ac45
parentf86bdd9900343fd99c1af1d1418ce26a4d42c955 (diff)
downloadraven-9416b79979ecce1aa2c0b18930a9fd87cd7f0432.tar.gz
Fixed up context handling for django to make breadcrumbs work
-rw-r--r--raven/context.py5
-rw-r--r--raven/contrib/django/models.py6
2 files changed, 8 insertions, 3 deletions
diff --git a/raven/context.py b/raven/context.py
index 9a66b98..cb2efbf 100644
--- a/raven/context.py
+++ b/raven/context.py
@@ -84,7 +84,6 @@ class Context(local, Mapping, Iterable):
_active_contexts.__dict__.setdefault('contexts', set()).add(self)
def deactivate(self):
- self.clear()
try:
_active_contexts.contexts.discard(self)
except AttributeError:
@@ -106,10 +105,12 @@ class Context(local, Mapping, Iterable):
def get(self):
return self.data
- def clear(self):
+ def clear(self, deactivate=True):
self.data = {}
self.exceptions_to_skip.clear()
self.breadcrumbs.clear()
+ if deactivate:
+ self.deactivate()
import raven.breadcrumbs
diff --git a/raven/contrib/django/models.py b/raven/contrib/django/models.py
index b2014c9..490978a 100644
--- a/raven/contrib/django/models.py
+++ b/raven/contrib/django/models.py
@@ -181,7 +181,11 @@ def sentry_exception_handler(request=None, **kwargs):
def register_handlers():
- from django.core.signals import got_request_exception
+ from django.core.signals import got_request_exception, request_started
+
+ def before_request(*args, **kwargs):
+ client.context.activate()
+ request_started.connect(before_request, weak=False)
# HACK: support Sentry's internal communication
if 'sentry' in settings.INSTALLED_APPS: