Login

Interactive debugger and other Paste niceties

Author:
maxua
Posted:
September 19, 2009
Language:
Python
Version:
1.1
Tags:
print django debugging paste wsgi werkzeug
Score:
2 (after 2 ratings)

runserver with extra development tools:

  1. interactive debugger that pops up automatically if an exception occurs, courtesy of Werkzeug
  2. logging of print statements directly into HTML (div float), courtesy of Paste.

Credits: piranha.org.ua

 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
#!/usr/bin/env python
"""Requires Paste and Werkzeug, use pip/easy_install to install::
$ pip Paste
$ pip Werkzeug
"""
import os
import sys

from werkzeug import run_simple, DebuggedApplication
from django.views import debug
from django.core.handlers.wsgi import WSGIHandler

def null_technical_500_response(request, exc_type, exc_value, tb):
    raise exc_type, exc_value, tb
debug.technical_500_response = null_technical_500_response

os.environ['DJANGO_SETTINGS_MODULE'] = 'YOURPROJ.settings'

from paste.debug.prints import PrintDebugMiddleware

app = WSGIHandler()
app = PrintDebugMiddleware(app)
app = DebuggedApplication(app, True)

if __name__ == '__main__':
    try:
        port = int(sys.argv[1])
    except (ValueError, IndexError):
        port = 8000
    run_simple('0.0.0.0', port, app, True)

More like this

  1. Interactive Profiling Middleware by sfllaw 4 years, 7 months ago
  2. RequestFetchingMixin by eternicode 4 years, 1 month ago
  3. Improved command to generate UML diagrams of whole project or specified apps by nikolajusk 4 years, 4 months ago
  4. Command to dump data as a python script by willhardy 6 years, 8 months ago
  5. Google Closure support in django-compress by fabrice.bonny 5 years, 3 months ago

Comments

Please login first before commenting.