summaryrefslogtreecommitdiff
path: root/cherrypy/lib/cptools.py
diff options
context:
space:
mode:
authorRobert Brewer <fumanchu@aminus.org>2006-05-01 06:40:59 +0000
committerRobert Brewer <fumanchu@aminus.org>2006-05-01 06:40:59 +0000
commit91bf8b763dce2f8925de9b64a4f7b18842daa2ae (patch)
tree63b9e474e4e5c7c110dce594438642c0806058d3 /cherrypy/lib/cptools.py
parentf65675aab4059833be021b7b384c766789f5c25f (diff)
downloadcherrypy-git-91bf8b763dce2f8925de9b64a4f7b18842daa2ae.tar.gz
Lots of changes to error and log handling:
1. Removed RequestHandled and InternalError. 2. Error response is now overridable by replacing request.error_response. Tools should do this in setup(). 3. New request.log_access attribute. 4. Moved response.handleError to request.handle_error. 5. Logging of tracebacks and request headers are now tools. 6. New ErrorRedirect tool class. 7. Tools may now be anonymous (not necessary to be placed in tools module globals). 8. Continued the move to lower_with_underscores.
Diffstat (limited to 'cherrypy/lib/cptools.py')
-rw-r--r--cherrypy/lib/cptools.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/cherrypy/lib/cptools.py b/cherrypy/lib/cptools.py
index dc5ed1d7..180ac434 100644
--- a/cherrypy/lib/cptools.py
+++ b/cherrypy/lib/cptools.py
@@ -8,7 +8,6 @@ import time
import cherrypy
-
def decorate(func, decorator):
"""
Return the decorated func. This will automatically copy all
@@ -314,4 +313,16 @@ def virtual_host(use_x_forwarded_host=True, **domains):
if prefix:
cherrypy.request.object_path = prefix + "/" + cherrypy.request.object_path
+def log_traceback():
+ """Write the last error's traceback to the cherrypy error log."""
+ from cherrypy import _cperror
+ cherrypy.log(_cperror.format_exc(), "HTTP")
+
+def log_request_headers():
+ """Write the last error's traceback to the cherrypy error log."""
+ h = [" %s: %s" % (k, v) for k, v in cherrypy.request.header_list]
+ cherrypy.log('\nRequest Headers:\n' + '\n'.join(h), "HTTP")
+def redirect(url=''):
+ """Raise cherrypy.HTTPRedirect to the given url."""
+ raise cherrypy.HTTPRedirect(url)