Skip to content
This repository
Browse code

Register sentry namespace in app.extensions (Flask)

  • Loading branch information...
commit 0852cf5a96e23c982b410efd07b3e5b78b401356 1 parent 1563b4d
David Cramer dcramer authored
4 raven/contrib/flask/__init__.py
@@ -95,6 +95,10 @@ def init_app(self, app):
95 95
96 96 got_request_exception.connect(self.handle_exception, sender=app)
97 97
  98 + if not hasattr(app, 'extensions'):
  99 + app.extensions = {}
  100 + app.extensions['sentry'] = self
  101 +
98 102 def captureException(self, *args, **kwargs):
99 103 assert self.client, 'captureException called before application configured'
100 104 return self.client.captureException(*args, **kwargs)
6 tests/contrib/flask/tests.py
@@ -32,6 +32,12 @@ def setUp(self):
32 32 self.app = create_app()
33 33 self.client = self.app.test_client()
34 34
  35 + def test_does_add_to_extensions(self):
  36 + client = TempStoreClient()
  37 + sentry = Sentry(self.app, client=client)
  38 + self.assertIn('sentry', self.app.extensions)
  39 + self.assertEquals(self.app.extensions['sentry'], sentry)
  40 +
35 41 def test_error_handler(self):
36 42 client = TempStoreClient()
37 43 sentry = Sentry(self.app, client=client)

0 comments on commit 0852cf5

Please sign in to comment.
Something went wrong with that request. Please try again.