[open-ils-commits] r883 - in servres/trunk: . conifer/syrup/views (gfawcett)
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed May 5 21:24:38 EDT 2010
Author: gfawcett
Date: 2010-05-05 21:24:37 -0400 (Wed, 05 May 2010)
New Revision: 883
Modified:
servres/trunk/.gitignore
servres/trunk/conifer/syrup/views/_common.py
Log:
* conifer/syrup/views/_common.py: added @postmortem decorator
When settings.DEBUG == True, a function decorated with @postmortem
will drop the Python process into the interactive postmortem debugger
if an uncaught exception is raised. (See the 'pdb' stdlib module for
details.)
Modified: servres/trunk/.gitignore
===================================================================
--- servres/trunk/.gitignore 2010-05-06 01:24:34 UTC (rev 882)
+++ servres/trunk/.gitignore 2010-05-06 01:24:37 UTC (rev 883)
@@ -9,3 +9,5 @@
TAGS
private_local_settings.py
/conifer/.dired
+/conifer/local_settings.py
+*~
\ No newline at end of file
Modified: servres/trunk/conifer/syrup/views/_common.py
===================================================================
--- servres/trunk/conifer/syrup/views/_common.py 2010-05-06 01:24:34 UTC (rev 882)
+++ servres/trunk/conifer/syrup/views/_common.py 2010-05-06 01:24:37 UTC (rev 883)
@@ -1,6 +1,7 @@
import warnings
from conifer.syrup import models
from datetime import datetime
+import django.conf
from django.contrib.auth import authenticate, login, logout
from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import User, SiteProfileNotAvailable
@@ -23,6 +24,7 @@
from conifer.syrup.fuzzy_match import rank_pending_items
from django.core.urlresolvers import reverse
from conifer.here import HERE
+import pdb
#-----------------------------------------------------------------------------
# Z39.50 Support
@@ -224,3 +226,19 @@
'instructors': (Q(member__course__access__in=('LOGIN','ANON')) | Q(member__course__member__user=user)),
}
return filters
+
+#------------------------------------------------------------
+
+# decorator
+def postmortem(func):
+ """Drop into a debugger if an error occurs in the decoratee."""
+ def inner(*args, **kwargs):
+ try:
+ return func(*args, **kwargs)
+ except Exception, e:
+ print '!!!!!!', e
+ pdb.post_mortem()
+ if django.conf.settings.DEBUG:
+ return inner
+ else:
+ return func
More information about the open-ils-commits
mailing list