File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed
Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change 77from roundup .i18n import _
88from roundup .anypy .strings import b2s , s2b
99
10+
1011def pack_timestamp ():
1112 return b2s (base64 .b64encode (struct .pack ("i" , int (time .time ()))).strip ())
1213
14+
1315def unpack_timestamp (s ):
1416 try :
15- timestamp = struct .unpack ("i" ,base64 .b64decode (s2b (s )))[0 ]
16- except (struct .error , binascii .Error , TypeError ) as e :
17+ timestamp = struct .unpack ("i" , base64 .b64decode (s2b (s )))[0 ]
18+ except (struct .error , binascii .Error , TypeError ):
1719 raise FormError (_ ("Form is corrupted." ))
1820 return timestamp
1921
22+
2023class Timestamped :
21- def timecheck (self ,field ,delay ):
24+ def timecheck (self , field , delay ):
2225 try :
2326 created = unpack_timestamp (self .form [field ].value )
2427 except KeyError :
25- raise FormError (_ ("Form is corrupted, missing: %s." % field ))
28+ raise FormError (_ ("Form is corrupted, missing: %s." % field ))
2629 if time .time () - created < delay :
2730 raise FormError (_ ("Responding to form too quickly." ))
2831 return True
You can’t perform that action at this time.
0 commit comments