[FIX] Error reports
[cds-indico.git] / indico / MaKaC / webinterface / rh / errors.py
blobf98a39621112a91a0a6fc362ef426e8aa7dd4aca
1 # -*- coding: utf-8 -*-
2 ##
3 ##
4 ## This file is part of CDS Indico.
5 ## Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 CERN.
6 ##
7 ## CDS Indico is free software; you can redistribute it and/or
8 ## modify it under the terms of the GNU General Public License as
9 ## published by the Free Software Foundation; either version 2 of the
10 ## License, or (at your option) any later version.
12 ## CDS Indico is distributed in the hope that it will be useful, but
13 ## WITHOUT ANY WARRANTY; without even the implied warranty of
14 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 ## General Public License for more details.
17 ## You should have received a copy of the GNU General Public License
18 ## along with CDS Indico; if not, write to the Free Software Foundation, Inc.,
19 ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
21 import MaKaC.webinterface.pages.errors as errors
22 from MaKaC.webinterface.rh.base import RH
23 from MaKaC.common import Config
24 from MaKaC.webinterface.mail import GenericMailer, GenericNotification
26 class RHErrorReporting(RH):
27 """Handles the reporting of errors to the Indico support.
29 This handler is quite special as it has to handle the reporting of
30 generic errors to the support of the application; any error can happen
31 which means that even the DB could not be avilable so it has to use
32 the minimal system resources possible in order to always be able to
33 report errors.
34 """
36 def _checkParams( self, params ):
37 self._sendIt = params.has_key( "confirm" )
38 self._comments = ""
39 if self._sendIt:
40 self._comments = params.get("comments", "")
41 self._userMail = params.get("userEmail", "")
42 self._msg = params.get("reportMsg", "")
45 def _sendReport( self ):
46 cfg = Config.getInstance()
47 fromAddr = self._userMail
48 toAddr = cfg.getSupportEmail()
49 subject = "[Indico@%s] Error report"%cfg.getBaseURL()
50 body = ["-"*20, "User Comments\n", "%s\n\n"%self._comments, "-"*20, \
51 "Error details\n", self._msg, "-"*20 ]
52 maildata = { "fromAddr": fromAddr, "toList": [toAddr], "subject": subject, "body": "\n".join( body ) }
53 GenericMailer.send(GenericNotification(maildata), skipQueue=True)
55 def process( self, params ):
56 self._checkParams( params )
57 if self._sendIt:
58 self._sendReport()
59 p = errors.WPReportErrorSummary( self )
60 return p.display()
61 else:
62 p = errors.WPReportError( self )
63 return p.display( userEmail = self._userMail, msg = self._msg )