Login

Interactive debugger and other Paste niceties

Author:
maxua
Posted:
September 19, 2009
Language:
Python
Version:
1.1
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. Template tag - list punctuation for a list of items by shapiromatron 2 months, 2 weeks ago
  2. JSONRequestMiddleware adds a .json() method to your HttpRequests by cdcarter 2 months, 3 weeks ago
  3. Serializer factory with Django Rest Framework by julio 9 months, 2 weeks ago
  4. Image compression before saving the new model / work with JPG, PNG by Schleidens 10 months, 1 week ago
  5. Help text hyperlinks by sa2812 11 months ago

Comments

Please login first before commenting.