Add PDB on exception debug tool and config setting

This commit is contained in:
Roberto Rosario
2012-07-29 01:14:32 -04:00
parent d1e59b1d7b
commit 6fa0c226b0
2 changed files with 20 additions and 0 deletions

View File

@@ -22,6 +22,10 @@ from .utils import validate_path
from .links import (password_change_view, current_user_details, from .links import (password_change_view, current_user_details,
current_user_edit, about_view, license_view, admin_site, sentry) current_user_edit, about_view, license_view, admin_site, sentry)
from .models import AutoAdminSingleton from .models import AutoAdminSingleton
from .debug import insert_pdb_exception_hook
if getattr(settings, 'DEBUG_ON_EXCEPTION', False):
insert_import_hook()
bind_links(['about_view', 'license_view'], [about_view, license_view], menu_name='secondary_menu') bind_links(['about_view', 'license_view'], [about_view, license_view], menu_name='secondary_menu')
bind_links(['current_user_details', 'current_user_edit', 'password_change_view'], [current_user_details, current_user_edit, password_change_view], menu_name='secondary_menu') bind_links(['current_user_details', 'current_user_edit', 'password_change_view'], [current_user_details, current_user_edit, password_change_view], menu_name='secondary_menu')

16
apps/common/debug.py Normal file
View File

@@ -0,0 +1,16 @@
import sys, pdb
previous_except_hook = None
def except_hook(exctype, value, traceback):
if previous_except_hook:
previous_except_hook(exctype, value, traceback)
pdb.post_mortem(traceback)
def insert_pdb_exception_hook():
previous_except_hook = sys.excepthook
sys.excepthook = except_hook