← Blog Home

python Blog Posts

Ad-hoc error reporting with Rollbar CLI

Written By Cory Virok August 8th, 2013
We just coded up a quick tool to send Rollbar messages from the command line. It’s useful for quick, one-off monitoring scripts that you don’t have time to instrument with one of our notifiers.
Read more

JavaScript and Source Maps in a Django App

Written By Sergei Bezborodko August 2nd, 2013

It’s pretty well known that every web app needs frontend JavaScript these days to provide the best possible user experience. You are probably going to have a bunch of JavaScript files that need to be loaded by your users for that to happen, and since we all care about performance, minifiying and compressing these files is an absolute must. But what happens when it comes time to debug issues in these minified files? Stack traces will more or less be completely useless. How do we solve this problem?

JavaScript source maps solve this problem. They allow you to map a point in a minified file back to the unminfied source, making it possible to actually identify and fix issues encountered in a production app environment.

Below I have outlined a simple guide for setting up source map generation and usage in a sample Django app. You’ll learn how generate source maps for minified files, debug errors that happen in these files, and also a quick overview of what’s required to get this working for your production environments.

Read more

Using a Request Factory in Pyramid to write a little less code

Written By Brian Rue September 7th, 2012

At Rollbar.com, we’ve been using Pyramid as our web framework and have been pretty happy with it. It’s lightweight and mostly stays out of our way.

Pyramid doesn’t have a global request object that you can just import[1], so it makes you pass around request wherever you need it. That results in a lot of library code that looks like this:

# lib/helpers.py
def flash_success(request, body, title=''):
    request.session.flash({'body': body, 'title': title'})

and a lot of view code that looks like this:

# views/auth.py
def login(request):
    # (do the login...)
    helpers.flash_success(request, "You're now logged in.")
    # (redirect...)

That is, there ends up being a lot of function calls that pass request as their first argument. Wouldn’t it be nicer if we could attach these functions as methods on request itself? That would save a few characters every time we call them, and let us stop thinking about whether request is the first or last argument. Pyramid facilitates this by letting us provide our own Request Factory:

Read more

Join Our Community

Get the latest updates, tutorials and more, delivered to your inbox, once a month.

Join Our Community

Get the latest updates, tutorials and more, delivered to your inbox, once a month.