diff options
author | Allan Saddi <allan@saddi.com> | 2006-02-24 00:16:01 +0000 |
---|---|---|
committer | Allan Saddi <allan@saddi.com> | 2006-02-24 00:16:01 +0000 |
commit | 3ee02462aa77244c6ce4e28845efc467a58e302f (patch) | |
tree | b6ff515a2d7dc7cbd6de2de64c327da8f3b5a2a9 /flup/server/fcgi_base.py | |
parent | a50fbcdb8df6ca67809547f03771c6c424756c06 (diff) | |
download | flup-3ee02462aa77244c6ce4e28845efc467a58e302f.tar.gz |
Add paste.server_factory-compliant factories and respective
egg entry points. Add debug option to servers, which is True
by default.
Diffstat (limited to 'flup/server/fcgi_base.py')
-rw-r--r-- | flup/server/fcgi_base.py | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/flup/server/fcgi_base.py b/flup/server/fcgi_base.py index 94c6285..52c95dc 100644 --- a/flup/server/fcgi_base.py +++ b/flup/server/fcgi_base.py @@ -1,4 +1,4 @@ -# Copyright (c) 2002, 2003, 2005 Allan Saddi <allan@saddi.com> +# Copyright (c) 2002, 2003, 2005, 2006 Allan Saddi <allan@saddi.com> # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -899,7 +899,8 @@ class BaseFCGIServer(object): def __init__(self, application, environ=None, multithreaded=True, multiprocess=False, - bindAddress=None, multiplexed=False): + bindAddress=None, multiplexed=False, + debug=True): """ bindAddress, if present, must either be a string or a 2-tuple. If present, run() will open its own listening socket. You would use @@ -924,6 +925,7 @@ class BaseFCGIServer(object): self.environ = environ self.multithreaded = multithreaded self.multiprocess = multiprocess + self.debug = debug self._bindAddress = bindAddress @@ -1135,6 +1137,18 @@ class BaseFCGIServer(object): Called by Request if an exception occurs within the handler. May and should be overridden. """ - import cgitb - req.stdout.write('Content-Type: text/html\r\n\r\n' + - cgitb.html(sys.exc_info())) + if self.debug: + import cgitb + req.stdout.write('Content-Type: text/html\r\n\r\n' + + 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> +""" + req.stdout.write('Content-Type: text/html\r\n\r\n' + + errorpage) |