Skip to content

Commit

Permalink
Merge pull request #150 from rollbar/fix-booleans-in-pyramid
Browse files Browse the repository at this point in the history
Fix settings values not being booleans in Pyramid
  • Loading branch information
ezarowny authored Dec 14, 2016
2 parents 732a23b + ca4e9b2 commit 765cf1f
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions rollbar/contrib/pyramid/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@
import rollbar

DEFAULT_WEB_BASE = 'https://rollbar.com'
BOOLEAN_SETTINGS = [
'rollbar.enabled', 'rollbar.allow_logging_basic_config',
'rollbar.verify_https'
]

log = logging.getLogger(__name__)


def handle_error(settings, request):
rollbar.report_exc_info(sys.exc_info(), request)

Expand All @@ -25,7 +30,10 @@ def parse_settings(settings):
out = {}
for k, v in settings.items():
if k.startswith(prefix):
if k in BOOLEAN_SETTINGS:
v = asbool(v)
out[k[len(prefix):]] = v

return out


Expand All @@ -39,7 +47,7 @@ def rollbar_tween(request):
# for testing out the integration
try:
if (settings.get('allow_test', 'true') == 'true' and
request.GET.get('pyramid_rollbar_test') == 'true'):
request.GET.get('pyramid_rollbar_test') == 'true'):
try:
raise Exception("pyramid_rollbar test exception")
except:
Expand Down Expand Up @@ -90,9 +98,11 @@ def insert_rollbar_console(request, html):

# patch tbtools.Traceback.render_full
old_render_full = tbtools.Traceback.render_full

def new_render_full(self, request, *args, **kw):
html = old_render_full(self, request, *args, **kw)
return insert_rollbar_console(request, html)

tbtools.Traceback.render_full = new_render_full


Expand Down Expand Up @@ -163,7 +173,7 @@ def __init__(self, settings, app):
def __call__(self, environ, start_resp):
try:
return self.app(environ, start_resp)
except Exception as e:
except Exception:
from pyramid.request import Request
handle_error(self.settings, Request(environ))
raise

0 comments on commit 765cf1f

Please sign in to comment.