SVN: r23113 - trunk/quixote

Neil Schemenauer <nascheme-fVcApmY9cLvQ3/1i3zOLAti2O/[email protected]> Mon, 10 Nov 2003 13:08:07 -0500
Newsgroups gmane.comp.web.quixote.cvs
Message-ID <[email protected]>
Author: nascheme
Date: 2003-11-10 13:08:07 -0500 (Mon, 10 Nov 2003)
New Revision: 23113

Modified:
   trunk/quixote/publish.py
   trunk/quixote/sendmail.py
Log:
Use the quixote.sendmail module to send traceback email.


Modified: trunk/quixote/publish.py
===================================================================
--- trunk/quixote/publish.py	2003-11-10 16:52:11 UTC (rev 23112)
+++ trunk/quixote/publish.py	2003-11-10 18:08:07 UTC (rev 23113)
@@ -20,6 +20,7 @@
 from quixote.http_request import HTTPRequest, get_content_type
 from quixote.http_response import HTTPResponse
 from quixote.upload import HTTPUploadRequest
+from quixote.sendmail import sendmail
 
 try:
     import cgitb                        # Only available in Python 2.2
@@ -414,17 +415,10 @@
 
     def mail_error (self, msg, error_summary):
         """Send an email notifying someone of a traceback."""
+        sendmail('Quixote Traceback (%s)' % error_summary,
+                 msg, [self.config.error_email],
+                 from_addr=(self.config.error_email, socket.gethostname()))
 
-        cmd = "/usr/lib/sendmail '%s'" % self.config.error_email
-        pipe = os.popen(cmd, 'w')
-        pipe.write('Subject: Quixote Traceback (%s)\n' % error_summary)
-        pipe.write('From: %s <%s>\n' % (socket.gethostname(),
-                                        self.config.error_email))
-        pipe.write('To: %s\n' % self.config.error_email)
-        pipe.write('\n')
-        pipe.write(msg)
-        pipe.close()
-
     def get_namespace_stack (self):
         """get_namespace_stack() ->  [ module | instance | class ]
         """

Modified: trunk/quixote/sendmail.py
===================================================================
--- trunk/quixote/sendmail.py	2003-11-10 16:52:11 UTC (rev 23112)
+++ trunk/quixote/sendmail.py	2003-11-10 18:08:07 UTC (rev 23113)
@@ -13,8 +13,6 @@
 from types import ListType, TupleType, StringType
 from smtplib import SMTP
 
-from quixote import get_publisher
-
 rfc822_specials_re = re.compile(r'[\(\)\<\>\@\,\;\:\\\"\.\[\]]')
 
 class RFC822Mailbox:
@@ -201,6 +199,7 @@
     the standard library documentation) for details.
     """
     if config is None:
+        from quixote import get_publisher
         config = get_publisher().config
 
     if not isinstance(to_addrs, ListType):