Commit 11250012 authored by Shane Hathaway's avatar Shane Hathaway

When displaying a traceback as text, show it alone with a text/plain content type.

parent 771cfd4d
......@@ -13,7 +13,7 @@
##############################################################################
"""Site error log module.
$Id: SiteErrorLog.py,v 1.2 2002/04/03 20:43:55 shane Exp $
$Id: SiteErrorLog.py,v 1.3 2002/04/04 16:25:43 shane Exp $
"""
import os
......@@ -31,6 +31,7 @@ from Products.PageTemplates.PageTemplateFile import PageTemplateFile
from zExceptions.ExceptionFormatter import format_exception
from zLOG import LOG, ERROR
# Permission names
use_error_logging = 'Log Site Errors'
log_to_event_log = 'Log to the Event Log'
......@@ -204,6 +205,18 @@ class SiteErrorLog (SimpleItem):
return entry.copy()
return None
security.declareProtected(use_error_logging, 'getLogEntryAsText')
def getLogEntryAsText(self, id, RESPONSE=None):
"""Returns the specified log entry.
Makes a copy to prevent changes. Returns None if not found.
"""
entry = self.getLogEntryById(id)
if entry is None:
return 'Log entry not found or expired'
if RESPONSE is not None:
RESPONSE.setHeader('Content-Type', 'text/plain')
return entry['tb_text']
Globals.InitializeClass(SiteErrorLog)
......
......@@ -34,25 +34,16 @@ The specified log entry was not found. It may have expired.
</tr>
</table>
<div tal:condition="python: entry['tb_html'] and
not request.get('show_entry_as_text')">
<div tal:content="structure entry/tb_html">
Traceback
<div tal:condition="entry/tb_html" tal:content="structure entry/tb_html">
Traceback (HTML)
</div>
<pre tal:condition="not:entry/tb_html" tal:content="entry/tb_text">
Traceback (text)
</pre>
<p tal:condition="entry/tb_text"><a href="" tal:attributes="href
string:showEntry?id=${entry/id}&show_entry_as_text=1">Display
string:getLogEntryAsText?id=${entry/id}">Display
traceback as text</a></p>
</div>
<div tal:condition="python: not entry['tb_html'] or
request.get('show_entry_as_text')">
<pre tal:content="entry/tb_text">
Traceback
</pre>
<p tal:condition="entry/tb_html"><a href="" tal:attributes="href
string:showEntry?id=${entry/id}">Display
traceback as HTML</a></p>
</div>
<div tal:condition="entry/req_html">
<h3>REQUEST</h3>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment