summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d5597ec)
raw | patch | inline | side by side (parent: d5597ec)
author | schlatterbeck <schlatterbeck@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Fri, 7 Oct 2011 19:08:54 +0000 (19:08 +0000) | ||
committer | schlatterbeck <schlatterbeck@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Fri, 7 Oct 2011 19:08:54 +0000 (19:08 +0000) |
- now this mail is a multipart/alternative with the HTML part *and* the
traceback in text-format.
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/roundup/trunk@4656 57a73879-2fb5-44c3-a270-3262357dd7e2
traceback in text-format.
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/roundup/trunk@4656 57a73879-2fb5-44c3-a270-3262357dd7e2
roundup/cgi/client.py | patch | blob | history |
diff --git a/roundup/cgi/client.py b/roundup/cgi/client.py
index b4147d47923e46fb047baa225def472f13846fad..11a22172e9c1f69437c139afa66525d78d6986a1 100644 (file)
--- a/roundup/cgi/client.py
+++ b/roundup/cgi/client.py
import base64, binascii, cgi, codecs, mimetypes, os
import quopri, random, re, rfc822, stat, sys, time
import socket, errno
import base64, binascii, cgi, codecs, mimetypes, os
import quopri, random, re, rfc822, stat, sys, time
import socket, errno
+from traceback import format_exc
from roundup import roundupdb, date, hyperdb, password
from roundup.cgi import templating, cgitb, TranslationService
from roundup import roundupdb, date, hyperdb, password
from roundup.cgi import templating, cgitb, TranslationService
from roundup.anypy import http_
from roundup.anypy import urllib_
from roundup.anypy import http_
from roundup.anypy import urllib_
+from email.MIMEBase import MIMEBase
+from email.MIMEText import MIMEText
+from email.MIMEMultipart import MIMEMultipart
+
def initialiseSecurity(security):
'''Create some Permissions and Roles on the security object
def initialiseSecurity(security):
'''Create some Permissions and Roles on the security object
if not self.instance.config.WEB_DEBUG:
exc_info = sys.exc_info()
subject = "Error: %s" % exc_info[1]
if not self.instance.config.WEB_DEBUG:
exc_info = sys.exc_info()
subject = "Error: %s" % exc_info[1]
- self.send_html_to_admin(subject, html)
+ self.send_error_to_admin(subject, html, format_exc())
self.write_html(self._(error_message))
else:
self.write_html(html)
self.write_html(self._(error_message))
else:
self.write_html(html)
self.additional_headers['Content-Length'] = str(len(content))
self.write(content)
self.additional_headers['Content-Length'] = str(len(content))
self.write(content)
- def send_html_to_admin(self, subject, content):
-
+ def send_error_to_admin(self, subject, html, txt):
+ """Send traceback information to admin via email.
+ We send both, the formatted html (with more information) and
+ the text version of the traceback. We use
+ multipart/alternative so the receiver can chose which version
+ to display.
+ """
to = [self.mailer.config.ADMIN_EMAIL]
to = [self.mailer.config.ADMIN_EMAIL]
- message = self.mailer.get_standard_message(to, subject)
- # delete existing content-type headers
- del message['Content-type']
- message['Content-type'] = 'text/html; charset=utf-8'
- message.set_payload(content)
- encode_quopri(message)
+ message = MIMEMultipart('alternative')
+ self.mailer.set_message_attributes(message, to, subject)
+ part = MIMEBase('text', 'html')
+ part.set_charset('utf-8')
+ part.set_payload(html)
+ encode_quopri(part)
+ message.attach(part)
+ part = MIMEText(txt)
+ message.attach(part)
self.mailer.smtp_send(to, message.as_string())
def renderFrontPage(self, message):
self.mailer.smtp_send(to, message.as_string())
def renderFrontPage(self, message):
# If possible, send the HTML page template traceback
# to the administrator.
subject = "Templating Error: %s" % exc_info[1]
# If possible, send the HTML page template traceback
# to the administrator.
subject = "Templating Error: %s" % exc_info[1]
- self.send_html_to_admin(subject, cgitb.pt_html())
+ self.send_error_to_admin(subject, cgitb.pt_html(), format_exc())
# Now report the error to the user.
return self._(error_message)
except:
# Now report the error to the user.
return self._(error_message)
except: