[Zope-Checkins] CVS: Packages/ZPublisher - HTTPResponse.py:1.54

Evan Simpson evan@zope.com
Fri, 15 Mar 2002 17:34:17 -0500


Update of /cvs-repository/Packages/ZPublisher
In directory cvs.zope.org:/tmp/cvs-serv1034

Modified Files:
	HTTPResponse.py 
Log Message:
Merge change from Zope-2_5-branch


=== Packages/ZPublisher/HTTPResponse.py 1.53 => 1.54 ===
 __version__='$Revision$'[11:-2]
 
-import  types, sys,  re
+import types, os, sys, re
 from string import translate, maketrans
 from types import StringType, InstanceType, LongType
 from BaseResponse import BaseResponse
@@ -92,6 +92,17 @@
 
 accumulate_header={'set-cookie': 1}.has_key
 
+tb_style = os.environ.get('HTTP_TRACEBACK_STYLE', '').lower()
+if tb_style == 'none':
+    tb_delims = None, None
+elif tb_style == 'js':
+    tb_delims = ('''<pre onclick="this.firstChild.data=this.lastChild.data">
+        &sect;<!--''',  '--></pre>')
+elif tb_style == 'plain':
+    tb_delims = '<pre>', '</pre>'
+else:
+    tb_delims = '<!--', '-->'
+
 class HTTPResponse(BaseResponse):
     """\
     An object representation of an HTTP response.
@@ -399,9 +410,9 @@
         tb = '\n'.join(tb)
         tb = self.quoteHTML(tb)
         if self.debug_mode: _tbopen, _tbclose = '<PRE>', '</PRE>'
-        else:               _tbopen, _tbclose = '''<pre
-          onclick="this.firstChild.data=this.lastChild.data">
-        &sect;<!--''',  '--></pre>'
+        else:               _tbopen, _tbclose = tb_delims
+        if _tbopen is None:
+            return ''
         return "\n%s\n%s\n%s" % (_tbopen, tb, _tbclose)
 
     def redirect(self, location, status=302, lock=0):