comparison roundup/cgi/client.py @ 4045:82213b1971b4

Only feed back traceback to web users if config.WEB_DEBUG is True
author Stefan Seefeld <stefan@seefeld.name>
date Tue, 17 Feb 2009 01:36:11 +0000
parents 39ad32d47cfb
children 48be910ebda1
comparison
equal deleted inserted replaced
4044:27a9906cd8d1 4045:82213b1971b4
1 # $Id: client.py,v 1.239 2008-08-18 05:04:02 richard Exp $
2
3 """WWW request handler (also used in the stand-alone server). 1 """WWW request handler (also used in the stand-alone server).
4 """ 2 """
5 __docformat__ = 'restructuredtext' 3 __docformat__ = 'restructuredtext'
6 4
7 import base64, binascii, cgi, codecs, mimetypes, os 5 import base64, binascii, cgi, codecs, mimetypes, os
8 import random, re, rfc822, stat, time, urllib, urlparse 6 import quopri random, re, rfc822, stat, sys, time, urllib, urlparse
9 import Cookie, socket, errno 7 import Cookie, socket, errno
10 from Cookie import CookieError, BaseCookie, SimpleCookie 8 from Cookie import CookieError, BaseCookie, SimpleCookie
9 from cStringIO import StringIO
11 10
12 from roundup import roundupdb, date, hyperdb, password 11 from roundup import roundupdb, date, hyperdb, password
13 from roundup.cgi import templating, cgitb, TranslationService 12 from roundup.cgi import templating, cgitb, TranslationService
14 from roundup.cgi.actions import * 13 from roundup.cgi.actions import *
15 from roundup.exceptions import * 14 from roundup.exceptions import *
925 return '<strong>%s</strong>'%message 924 return '<strong>%s</strong>'%message
926 except templating.Unauthorised, message: 925 except templating.Unauthorised, message:
927 raise Unauthorised, str(message) 926 raise Unauthorised, str(message)
928 except: 927 except:
929 # everything else 928 # everything else
930 return cgitb.pt_html(i18n=self.translator) 929 if self.instance.config.WEB_DEBUG:
930 return cgitb.pt_html(i18n=self.translator)
931 exc_info = sys.exc_info()
932 try:
933 # If possible, send the HTML page template traceback
934 # to the administrator.
935 to = [self.mailer.config.ADMIN_EMAIL]
936 subject = "Templating Error: %s" % exc_info[1]
937 content = cgitb.pt_html()
938 message, writer = self.mailer.get_standard_message(
939 to, subject)
940 writer.addheader('Content-Transfer-Encoding', 'quoted-printable')
941 body = writer.startbody('text/html; charset=utf-8')
942 content = StringIO(content)
943 quopri.encode(content, body, 0)
944 self.mailer.smtp_send(to, message)
945 # Now report the error to the user.
946 return self._(error_message)
947 except:
948 # Reraise the original exception. The user will
949 # receive an error message, and the adminstrator will
950 # receive a traceback, albeit with less information
951 # than the one we tried to generate above.
952 raise exc_info[0], exc_info[1], exc_info[2]
931 953
932 # these are the actions that are available 954 # these are the actions that are available
933 actions = ( 955 actions = (
934 ('edit', EditItemAction), 956 ('edit', EditItemAction),
935 ('editcsv', EditCSVAction), 957 ('editcsv', EditCSVAction),

Roundup Issue Tracker: http://roundup-tracker.org/