twipping the rift

“I like nonsense, it wakes up the brain cells. Fantasy is a necessary ingredient in living, it’s a way of looking at life through the wrong end of a telescope. Which is what I do, and that enables you to laugh at life’s realities.” - Dr. Seuss

Django Debugging Helper

I found this to be extremely helpful inside my django source to aid in debugging Ajax and other server 500 errors. At the bottom of this function add the following lines:

def technical_500_response(request, exc_type, exc_value, tb):
    """
    Create a technical server error response. The last three arguments are
    the values returned from sys.exc_info() and friends.
    """

    # ... skip to the end of the function

    print '-' * 80
    print ' 500 Exception', c['exception_type'], c['exception_value']
    print '     url:', request.path, '\n'
    for fr in [ frames[i] for i in range( len(frames)-1, 0, -1 ) ]:
        print '   trace: [%5s] %-20s in %s' % (fr['lineno'] , fr['function'], fr['filename'] )
    print '-' * 80

    return HttpResponseServerError(t.render(c), mimetype='text/html')

Colophon

A technologist, runner, photographer, iPhone junkie.

Syndicate

Activity

One comment, leave your comment or trackback.
  1. you should submit this as a patch to get it into trunk on django


Leave a Reply


Search

The archives run deep. Feel free to search older content using topic keywords.

Browse by Category