comparison website/issues/extensions/timestamp.py @ 5378:35ea9b1efc14

Python 3 preparation: "raise" syntax. Changing "raise Exception, value" to "raise Exception(value)". Tool-assisted patch. Particular cases to check carefully are the one place in frontends/ZRoundup/ZRoundup.py where a string exception needed to be fixed, and the one in roundup/cgi/client.py involving raising an exception with a traceback (requires three-argument form of raise in Python 2, which as I understand it requires exec() to avoid a Python 3 syntax error).
author Joseph Myers <jsm@polyomino.org.uk>
date Tue, 24 Jul 2018 21:39:58 +0000
parents c2d0d3e9099d
children
comparison
equal deleted inserted replaced
5377:12fe83f90f0d 5378:35ea9b1efc14
11 class Timestamped: 11 class Timestamped:
12 def check(self): 12 def check(self):
13 try: 13 try:
14 created = unpack_timestamp(self.form['opaque'].value) 14 created = unpack_timestamp(self.form['opaque'].value)
15 except KeyError: 15 except KeyError:
16 raise FormError, "somebody tampered with the form" 16 raise FormError("somebody tampered with the form")
17 if time.time() - created < 4: 17 if time.time() - created < 4:
18 raise FormError, "responding to the form too quickly" 18 raise FormError("responding to the form too quickly")
19 return True 19 return True
20 20
21 class TimestampedRegister(Timestamped, RegisterAction): 21 class TimestampedRegister(Timestamped, RegisterAction):
22 def permission(self): 22 def permission(self):
23 self.check() 23 self.check()

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