summaryrefslogtreecommitdiff
path: root/docs/integrations/bottle.rst
blob: 4db312bf02b272e0f340a0e3bc11b4e7074fceca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
Bottle
======

`Bottle <http://bottlepy.org/>`_ is a microframework for Python.  Raven
supports this framework through the WSGI integration.

Installation
------------

If you haven't already, start by downloading Raven. The easiest way is
with *pip*::

	pip install raven --upgrade

Setup
-----

The first thing you'll need to do is to disable catchall in your Bottle app::

    import bottle

    app = bottle.app()
    app.catchall = False

.. note:: Bottle will not propagate exceptions to the underlying WSGI
          middleware by default. Setting catchall to False disables that.

Sentry will then act as Middleware::

    from raven import Client
    from raven.contrib.bottle import Sentry
    client = Client('___DSN___')
    app = Sentry(app, client)

Usage
-----

Once you've configured the Sentry application you need only call run with it::

    run(app=app)

If you want to send additional events, a couple of shortcuts are provided
on the Bottle request app object.

Capture an arbitrary exception by calling ``captureException``::

    try:
        1 / 0
    except ZeroDivisionError:
        request.app.sentry.captureException()

Log a generic message with ``captureMessage``::

    request.app.sentry.captureMessage('Hello, world!')