Geoff,
here's an updated patch for that email thing, including a config
setting.
Tavis
? Cans
? mod_webkit
? ExceptionHandler.diff
? email.diff
? Documentation
? appserverpid.txt
? Docs/GenIndex.css
? Native/mod_webkit.tgz
? Research/CustomImport.pyc
? Research/Reraise.pyc
? Research/TestTransports.pyc
? Tasks/SessionTask.pyc
? Tasks/__init__.pyc
Index: ExceptionHandler.py
===================================================================
RCS file: /cvsroot/webware/Webware/WebKit/ExceptionHandler.py,v
retrieving revision 1.14
diff -r1.14 ExceptionHandler.py
9c9,12
<
---
> import smtplib
> import MimeWriter
> import StringIO
> import traceback
324,339c327,368
< 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, '')
<
< # dbg code, in case you're having problems with your e-mail
< # open('error-email-msg.text', 'w').write(msg)
<
---
> def emailException(self, htmlErrMsg):
> message = StringIO.StringIO()
> writer = MimeWriter.MimeWriter(message)
>
> ## Construct the message headers
> headers = self.setting('ErrorEmailExtraHeaders')
> headers['Date'] = dateForEmail()
> headers['Subject'] = headers.get('Subject','[WebKit Error]') + ' ' \
> + str(sys.exc_info()[0])
> for h,v in headers.items():
> writer.addheader(h, v)
>
> ## Construct the message body
>
> if self.setting('EmailErrorReportAsAttachment', False):
> writer.startmultipartbody('mixed')
> # start off with a text/plain part
> part = writer.nextpart()
> body = part.startbody('text/plain')
> body.write(
> 'WebKit caught an exception while processing ' +
> 'a request for "%s" ' % self.servletPathname() +
> 'at %s (timestamp: %s). ' %
> (asctime(localtime(self._res.endTime()))), self._res.endTime()) +
> 'The plain text traceback from Python is printed below and ' +
> 'the full HTML error report from WebKit is attached.\n\n'
> )
> traceback.print_exc(file=body)
>
> # 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; name=WebKitErrorMsg.html')
> body.write(htmlErrMsg)
>
> # finish off
> writer.lastpart()
> else:
> body = writer.startbody('text/html')
> body.write(htmlErrMsg)
>
341d369
< import smtplib
344c372
< server.sendmail(headers['From'], headers['To'], msg)
---
> server.sendmail(headers['From'], headers['To'], message.getvalue())
Index: Configs/Application.config
===================================================================
RCS file: /cvsroot/webware/Webware/WebKit/Configs/Application.config,v
retrieving revision 1.43
diff -r1.43 Application.config
47c47,48
< 'EmailErrors': 0, # be sure to review the following settings when enabling error e-mails
---
> 'EmailErrors': 0, # be sure to review the following settings when enabling error e-mails
> 'EmailErrorReportAsAttachment':0, # send the html report as attachment rather than as message body
53c54
< 'Subject': 'Error',
---
> 'Subject': '[Webware Error]',