Hi!
I patched quixote (0.7a2) to write the html traceback
to a file. The html tracebacks contains more information than
the text version.
Thomas
--- config.py_orig 2004-02-19 11:25:07.000000000 +0100
+++ config.py 2004-02-19 11:11:31.000000000 +0100
@@ -37,6 +37,9 @@
ACCESS_LOG = None
#ACCESS_LOG = "/www/log/quixote-access.log"
+# The HTML traceback created by cgitb can be logged to a directory
+HTML_TRACEBACK_DIR = None
+
# Filename for logging error messages; if None, everything will be sent
# to standard error, so it should wind up in the Web server's error log
# file.
@@ -189,6 +192,7 @@
'access_log',
'debug_log',
'display_exceptions',
+ 'html_traceback_dir',
'secure_errors',
'error_log',
'run_once',
--- publish.py_0_7a2 2004-02-19 11:29:58.000000000 +0100
+++ publish.py 2004-02-19 11:23:23.000000000 +0100
@@ -116,6 +116,7 @@
self.namespace_stack = [self.root_namespace]
self.exit_now = 0
+ self.html_traceback_dir = None
self.access_log = None
self.error_log = sys.stderr # possibly overridden in setup_logs()
sys.stdout = self.error_log # print is handy for debugging
@@ -357,13 +358,36 @@
# secure (and cryptic) page.
request.response.set_header("Content-Type", "text/html")
user_error_msg = self._generate_internal_error(request)
- elif self.config.display_exceptions == 'html' and cgitb is not None:
+ elif cgitb and (self.config.display_exceptions == 'html' or \
+ self.config.html_traceback_dir):
# Generate a spiffy HTML display using cgitb
request.response.set_header("Content-Type", "text/html")
- user_error_msg = self._generate_cgitb_error(request,
+ html_error_msg = self._generate_cgitb_error(request,
original_response,
exc_type, exc_value,
tb)
+ if self.config.display_exceptions == 'html':
+ user_error_msg=html_error_msg
+
+ if self.config.html_traceback_dir:
+ # Write HTML-Traceback to file
+ now=time.time()
+
+ # Timestamp plus milliseconds for unique and sortable
filename
+ filename="%s-%s.html" % (time.strftime("%Y-%m-%d-%H-%M-%S",
+ time.localtime(now)),
+ long(now*10000)%10000)
+ if not os.path.isdir(self.config.html_traceback_dir):
+ self.error_log.write(
+ "html_traceback_dir does not exist: %s\n" %
+ self.config.html_traceback_dir)
+ else:
+ filename_abs=os.path.join(self.config.html_traceback_dir,
+ filename)
+ fd=open(filename_abs, "wt")
+ fd.write(html_error_msg)
+ fd.close()
+
else:
# Generate a plaintext page containing the traceback
request.response.set_header("Content-Type", "text/plain")
--
Thomas Güttler, TBZ-PARIV GmbH, Bernsdorfer Str. 210-212, 09126 Chemnitz
Tel.: 0371/5221217 Fax: 0371/5221216