Skip to content

Commit f324c84

Browse files
committed
refactor: move RateLimitExceeded to roundup.cgi.exceptions
RateLimitExceeded is an HTTP exception that raises code 429. Move it to roundup.cgi.exceptions where all the other exceptions that result in http status codes are located. Also make it inherit from HTTPException since it is one. Also add docstrings for all HTTP exceptions and order HTTPExceptions by status code. BREAKING CHANGE: if somebody is importing RateLimitExceeded they will need to change their import. I consider it unlikely anybody is using RateLimitExceeded. Detectors and extensions are unlikely to raise RateLimitExceeded. So I am leaving it out of the upgrading doc. Just doc in change log.
1 parent fbbe2b0 commit f324c84

File tree

5 files changed

+25
-10
lines changed

5 files changed

+25
-10
lines changed

CHANGES.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,19 @@ Roundup 2.0 supports Python 3.4 and later. Roundup 2.1.0 supports
1313
python 3.6 or newer (3.4/3.5 might work, but they are not tested).
1414
Roundup 2.4.0 is the last release to support Python 2.
1515

16+
2026-XX-XX 2.6.0
17+
18+
Fixed:
19+
20+
- performance improvement to session_dbm.py:clean(). Also add warning
21+
log message if clean takes longer than 3 seconds. (John Rouillard)
22+
- move RateLimitExceeded exception from roundup.exceptions to
23+
roundup.cgi.exceptions. Also it now inherits from HTTPException
24+
rather than Exception since it is an HTTP exception. (John
25+
Rouillard)
26+
27+
Features:
28+
1629
2025-07-13 2.5.0
1730

1831
Fixed:

roundup/cgi/actions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
from roundup.anypy.html import html_escape
1212
from roundup.anypy.strings import StringIO
1313
from roundup.cgi import exceptions, templating
14+
from roundup.cgi.exceptions import RateLimitExceeded
1415
from roundup.cgi.timestamp import Timestamped
15-
from roundup.exceptions import RateLimitExceeded, Reject, RejectRaw
16+
from roundup.exceptions import Reject, RejectRaw
1617
from roundup.i18n import _
1718
from roundup.mailgw import uidFromAddress
1819
from roundup.rate_limit import Gcra, RateLimit

roundup/cgi/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class SysCallError(Exception):
4040
IndexerQueryError,
4141
NotFound,
4242
NotModified,
43+
RateLimitExceeded,
4344
Redirect,
4445
SendFile,
4546
SendStaticFile,
@@ -48,7 +49,6 @@ class SysCallError(Exception):
4849
from roundup.cgi.form_parser import FormParser
4950
from roundup.exceptions import (
5051
LoginError,
51-
RateLimitExceeded,
5252
Reject,
5353
RejectRaw,
5454
Unauthorised,

roundup/cgi/exceptions.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,25 @@ class Redirect(HTTPException):
2424
pass
2525

2626

27+
class NotModified(HTTPException):
28+
"""HTTP 304 status code"""
29+
pass
30+
31+
2732
class NotFound(HTTPException):
2833
"""HTTP 404 status code unless self.response_code is set to
2934
400 prior to raising exception.
3035
"""
3136
pass
3237

3338

34-
class NotModified(HTTPException):
35-
"""HTTP 304 status code"""
39+
class PreconditionFailed(HTTPException):
40+
"""HTTP 412 status code"""
3641
pass
3742

3843

39-
class PreconditionFailed(HTTPException):
40-
"""HTTP 412 status code"""
44+
class RateLimitExceeded(HTTPException):
45+
"""HTTP 429 error code"""
4146
pass
4247

4348

roundup/exceptions.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ class LoginError(RoundupException):
1212
pass
1313

1414

15-
class RateLimitExceeded(Exception):
16-
pass
17-
18-
1915
class Unauthorised(RoundupException):
2016
pass
2117

0 commit comments

Comments
 (0)