comparison roundup/hyperdb.py @ 5084:675b3b3d88f0

Fix issue2550826 third try. This limits the capture of exceptions to Environment (includes the original IOError) and Arithmetic errors. It repackages these errors as detector exceptions so they can be reported. This allows the detectors to raise Reject and other exceptions and propagate them up from the detectors.
author John Rouillard <rouilj@ieee.org>
date Fri, 17 Jun 2016 22:10:01 -0400
parents 89d69a822e5c
children d043a09952db
comparison
equal deleted inserted replaced
5083:1c992cb4301a 5084:675b3b3d88f0
27 # roundup modules 27 # roundup modules
28 import date, password 28 import date, password
29 from support import ensureParentsExist, PrioList 29 from support import ensureParentsExist, PrioList
30 from roundup.i18n import _ 30 from roundup.i18n import _
31 from roundup.cgi.exceptions import DetectorError 31 from roundup.cgi.exceptions import DetectorError
32
33 # import other errors that a detector is allowed to throw
34 # so they can be raised and not captured by the DetectorError
35 from roundup.exceptions import Reject, RejectRaw
36 try:
37 from pytz import UnknownTimeZoneError
38 except:
39 UnknownTimeZoneError = ValueError
40 32
41 # 33 #
42 # Types 34 # Types
43 # 35 #
44 class _Type(object): 36 class _Type(object):
1300 def fireAuditors(self, event, nodeid, newvalues): 1292 def fireAuditors(self, event, nodeid, newvalues):
1301 """Fire all registered auditors""" 1293 """Fire all registered auditors"""
1302 for prio, name, audit in self.auditors[event]: 1294 for prio, name, audit in self.auditors[event]:
1303 try: 1295 try:
1304 audit(self.db, self, nodeid, newvalues) 1296 audit(self.db, self, nodeid, newvalues)
1305 except (Reject, RejectRaw, ValueError, UnknownTimeZoneError): 1297 except (EnvironmentError, ArithmeticError) as e:
1306 # these are raised by detectors to cause actions
1307 # to occur at other levels. Reassert them.
1308 raise
1309 except Exception as e:
1310 tb = traceback.format_exc() 1298 tb = traceback.format_exc()
1311 html = ("<h1>Traceback</h1>" + str(tb).replace('\n', '<br>'). 1299 html = ("<h1>Traceback</h1>" + str(tb).replace('\n', '<br>').
1312 replace(' ', '&nbsp;')) 1300 replace(' ', '&nbsp;'))
1313 txt = 'Caught exception %s: %s\n%s' % (str(type(e)), e, tb) 1301 txt = 'Caught exception %s: %s\n%s' % (str(type(e)), e, tb)
1314 exc_info = sys.exc_info() 1302 exc_info = sys.exc_info()
1322 def fireReactors(self, event, nodeid, oldvalues): 1310 def fireReactors(self, event, nodeid, oldvalues):
1323 """Fire all registered reactors""" 1311 """Fire all registered reactors"""
1324 for prio, name, react in self.reactors[event]: 1312 for prio, name, react in self.reactors[event]:
1325 try: 1313 try:
1326 react(self.db, self, nodeid, oldvalues) 1314 react(self.db, self, nodeid, oldvalues)
1327 except (Reject, RejectRaw, ValueError): 1315 except (EnvironmentError, ArithmeticError) as e:
1328 # these are raised by detectors to cause actions
1329 # to occur at other levels. Reassert them.
1330 raise
1331 except Exception as e:
1332 tb = traceback.format_exc() 1316 tb = traceback.format_exc()
1333 html = ("<h1>Traceback</h1>" + str(tb).replace('\n', '<br>'). 1317 html = ("<h1>Traceback</h1>" + str(tb).replace('\n', '<br>').
1334 replace(' ', '&nbsp;')) 1318 replace(' ', '&nbsp;'))
1335 txt = 'Caught exception %s: %s\n%s' % (str(type(e)), e, tb) 1319 txt = 'Caught exception %s: %s\n%s' % (str(type(e)), e, tb)
1336 exc_info = sys.exc_info() 1320 exc_info = sys.exc_info()

Roundup Issue Tracker: http://roundup-tracker.org/