diff options
Diffstat (limited to 'flup/server/ajp_base.py')
-rw-r--r-- | flup/server/ajp_base.py | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/flup/server/ajp_base.py b/flup/server/ajp_base.py index 76c2534..d3145f4 100644 --- a/flup/server/ajp_base.py +++ b/flup/server/ajp_base.py @@ -1,4 +1,4 @@ -# Copyright (c) 2005 Allan Saddi <allan@saddi.com> +# Copyright (c) 2005, 2006 Allan Saddi <allan@saddi.com> # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -754,7 +754,7 @@ class BaseAJPServer(object): def __init__(self, application, scriptName='', environ=None, multithreaded=True, multiprocess=False, bindAddress=('localhost', 8009), allowedServers=NoDefault, - loggingLevel=logging.INFO): + loggingLevel=logging.INFO, debug=True): """ scriptName is the initial portion of the URL path that "belongs" to your application. It is used to determine PATH_INFO (which doesn't @@ -789,6 +789,7 @@ class BaseAJPServer(object): self.environ = environ self.multithreaded = multithreaded self.multiprocess = multiprocess + self.debug = debug self._bindAddress = bindAddress if allowedServers is NoDefault: allowedServers = ['127.0.0.1'] @@ -926,6 +927,18 @@ class BaseAJPServer(object): Override to provide custom error handling. Ideally, however, all errors should be caught at the application level. """ - request.startResponse(200, 'OK', [('Content-Type', 'text/html')]) - import cgitb - request.write(cgitb.html(sys.exc_info())) + if self.debug: + request.startResponse(200, 'OK', [('Content-Type', 'text/html')]) + import cgitb + request.write(cgitb.html(sys.exc_info())) + else: + errorpage = """<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> +<html><head> +<title>Unhandled Exception</title> +</head><body> +<h1>Unhandled Exception</h1> +<p>An unhandled exception was thrown by the application.</p> +</body></html> +""" + request.startResponse(200, 'OK', [('Content-Type', 'text/html')]) + request.write(errorpage) |