[Python-checkins] r70402 - in tracker/roundup-src/roundup: cgi/client.py mailer.py

martin.v.loewis python-checkins at python.org
Sun Mar 15 23:06:49 CET 2009


Author: martin.v.loewis
Date: Sun Mar 15 23:06:49 2009
New Revision: 70402

Log:
Reapply r65325:
Put request information into exception emails.


Modified:
   tracker/roundup-src/roundup/cgi/client.py
   tracker/roundup-src/roundup/mailer.py

Modified: tracker/roundup-src/roundup/cgi/client.py
==============================================================================
--- tracker/roundup-src/roundup/cgi/client.py	(original)
+++ tracker/roundup-src/roundup/cgi/client.py	Sun Mar 15 23:06:49 2009
@@ -519,9 +519,21 @@
             if self.instance.config.WEB_DEBUG:
                 self.write_html(cgitb.html(i18n=self.translator))
             else:
-                self.mailer.exception_message()
+                self.mailer.exception_message(self.exception_data())
                 return self.write_html(self._(error_message))
 
+    def exception_data(self):
+        result = ''
+        try:
+            for k,v in self.env.items():
+                result += "%s=%s\n" % (k,v)
+            for k,v in self.request.headers.items():
+                result += "%s=%s\n" % (k,v)
+            result += "user:" + repr(self.user) + "\n"
+        except:
+            pass
+        return result
+
     def clean_sessions(self):
         """Deprecated
            XXX remove

Modified: tracker/roundup-src/roundup/mailer.py
==============================================================================
--- tracker/roundup-src/roundup/mailer.py	(original)
+++ tracker/roundup-src/roundup/mailer.py	Sun Mar 15 23:06:49 2009
@@ -169,14 +169,14 @@
             # because of spam)
             pass
 
-    def exception_message(self):
+    def exception_message(self, data=''):
         '''Send a message to the admins with information about the latest
         traceback.
         '''
         subject = '%s: %s'%(self.config.TRACKER_NAME, sys.exc_info()[1])
         to = [self.config.ADMIN_EMAIL]
         content = '\n'.join(traceback.format_exception(*sys.exc_info()))
-        self.standard_message(to, subject, content)
+        self.standard_message(to, subject, data+content)
 
     def smtp_send(self, to, message):
         """Send a message over SMTP, using roundup's config.


More information about the Python-checkins mailing list