Geoff,
here's a patch to make ExceptionHandler.py email the HTML error
reports as attachments rather than as part of the message body. It
makes it easier to save or forward them.
Tavis
Index: ExceptionHandler.py
===================================================================
RCS file: /cvsroot/webware/Webware/WebKit/ExceptionHandler.py,v
retrieving revision 1.14
diff -r1.14 ExceptionHandler.py
8a9,11
> import smtplib
> import MimeWriter
> import StringIO
324,335c327,350
< def emailException(self, html):
< # Construct the message
< headers = self.setting('ErrorEmailHeaders')
< msg = []
< for key, value in headers.items():
< if isinstance(value, types.ListType):
< value = string.join(value, ', ')
< msg.append('%s: %s\n' % (key, value))
< msg.append('Date: %s\n' % dateForEmail())
< msg.append('\n')
< msg.append(html)
< msg = string.join(msg, '')
---
> def emailException(self, htmlErrMsg):
> message = StringIO.StringIO()
> writer = MimeWriter.MimeWriter(message)
>
> ## Construct the message headers
> headers = self.setting('ErrorEmailExtraHeaders')
> headers['Date'] = dateForEmail()
> for h,v in headers.items():
> writer.addheader(h, v)
>
> ## Construct the message body
>
> writer.startmultipartbody('mixed')
> # start off with a text/plain part
> part = writer.nextpart()
> body = part.startbody('text/plain')
> body.write('WebKit caught an exception. Here is the html error report.')
>
> # now add htmlErrMsg
> part = writer.nextpart()
> part.addheader('Content-Transfer-Encoding', '7bit')
> part.addheader('Content-Description', 'HTML version of WebKit error message')
> body = part.startbody('text/html')
> body.write(htmlErrMsg)
337,338c352,353
< # dbg code, in case you're having problems with your e-mail
< # open('error-email-msg.text', 'w').write(msg)
---
> # finish off
> writer.lastpart()
341d355
< import smtplib
344c358
< server.sendmail(headers['From'], headers['To'], msg)
---
> server.sendmail(headers['From'], headers['To'], message.getvalue())