Skip to content

Instantly share code, notes, and snippets.

@x746e
Created July 17, 2012 12:25
Show Gist options
  • Save x746e/3129144 to your computer and use it in GitHub Desktop.
Save x746e/3129144 to your computer and use it in GitHub Desktop.
Make web2py show a traceback right away instead of creating a ticket and add a devserver with a reloader
diff --git a/gluon/main.py b/gluon/main.py
--- a/gluon/main.py
+++ b/gluon/main.py
@@ -796,6 +796,11 @@
log_filename,
profiler_filename) }
+ from werkzeug.serving import run_simple
+ app = app_info["wsgi_app"]
+ run_simple('localhost', 8000, app, use_reloader=True)
+
+ return
self.server = rocket.Rocket(interfaces or tuple(sock_list),
method='wsgi',
app_info=app_info,
diff --git a/gluon/restricted.py b/gluon/restricted.py
--- a/gluon/restricted.py
+++ b/gluon/restricted.py
@@ -208,13 +208,16 @@
# do not encapsulate (obfuscate) the original RestrictedError
raise
except Exception, error:
- # extract the exception type and value (used as output message)
- etype, evalue, tb = sys.exc_info()
- # XXX Show exception in Wing IDE if running in debugger
- if __debug__ and 'WINGDB_ACTIVE' in os.environ:
- sys.excepthook(etype, evalue, tb)
- output = "%s %s" % (etype, evalue)
- raise RestrictedError(layer, code, output, environment)
+ from traceback import format_exc
+ raise HTTP(500, u"<pre>%s</pre>" % format_exc())
+
+# # extract the exception type and value (used as output message)
+# etype, evalue, tb = sys.exc_info()
+# # XXX Show exception in Wing IDE if running in debugger
+# if __debug__ and 'WINGDB_ACTIVE' in os.environ:
+# sys.excepthook(etype, evalue, tb)
+# output = "%s %s" % (etype, evalue)
+# raise RestrictedError(layer, code, output, environment)
def snapshot(info=None, context=5, code=None, environment=None):
"""Return a dict describing a given traceback (based on cgitb.text)."""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment