Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Optional message for HTTP Errors #187

Merged
merged 1 commit into from

2 participants

@bflyblue

This commit broke being able to pass a message into Forbidden (and a few other HTTP errors):

f3b2738

My patch returns the functionality that was available in 0.36.

@aaronsw
Owner

Thanks. Would be good to add doctests for this too.

@aaronsw aaronsw merged commit 8af2c4a into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 26, 2012
  1. @bflyblue
This page is out of date. Refresh to see the latest.
Showing with 15 additions and 15 deletions.
  1. +15 −15 web/webapi.py
View
30 web/webapi.py
@@ -132,20 +132,20 @@ def __init__(self, message=None):
class Unauthorized(HTTPError):
"""`401 Unauthorized` error."""
message = "unauthorized"
- def __init__(self):
+ def __init__(self, message=None):
status = "401 Unauthorized"
headers = {'Content-Type': 'text/html'}
- HTTPError.__init__(self, status, headers, self.message)
+ HTTPError.__init__(self, status, headers, message or self.message)
unauthorized = Unauthorized
class Forbidden(HTTPError):
"""`403 Forbidden` error."""
message = "forbidden"
- def __init__(self):
+ def __init__(self, message=None):
status = "403 Forbidden"
headers = {'Content-Type': 'text/html'}
- HTTPError.__init__(self, status, headers, self.message)
+ HTTPError.__init__(self, status, headers, message or self.message)
forbidden = Forbidden
@@ -189,50 +189,50 @@ def __init__(self, cls=None):
class NotAcceptable(HTTPError):
"""`406 Not Acceptable` error."""
message = "not acceptable"
- def __init__(self):
+ def __init__(self, message=None):
status = "406 Not Acceptable"
headers = {'Content-Type': 'text/html'}
- HTTPError.__init__(self, status, headers, self.message)
+ HTTPError.__init__(self, status, headers, message or self.message)
notacceptable = NotAcceptable
class Conflict(HTTPError):
"""`409 Conflict` error."""
message = "conflict"
- def __init__(self):
+ def __init__(self, message=None):
status = "409 Conflict"
headers = {'Content-Type': 'text/html'}
- HTTPError.__init__(self, status, headers, self.message)
+ HTTPError.__init__(self, status, headers, message or self.message)
conflict = Conflict
class Gone(HTTPError):
"""`410 Gone` error."""
message = "gone"
- def __init__(self):
+ def __init__(self, message=None):
status = '410 Gone'
headers = {'Content-Type': 'text/html'}
- HTTPError.__init__(self, status, headers, self.message)
+ HTTPError.__init__(self, status, headers, message or self.message)
gone = Gone
class PreconditionFailed(HTTPError):
"""`412 Precondition Failed` error."""
message = "precondition failed"
- def __init__(self):
+ def __init__(self, message=None):
status = "412 Precondition Failed"
headers = {'Content-Type': 'text/html'}
- HTTPError.__init__(self, status, headers, self.message)
+ HTTPError.__init__(self, status, headers, message or self.message)
preconditionfailed = PreconditionFailed
class UnsupportedMediaType(HTTPError):
"""`415 Unsupported Media Type` error."""
message = "unsupported media type"
- def __init__(self):
+ def __init__(self, message=None):
status = "415 Unsupported Media Type"
headers = {'Content-Type': 'text/html'}
- HTTPError.__init__(self, status, headers, self.message)
+ HTTPError.__init__(self, status, headers, message or self.message)
unsupportedmediatype = UnsupportedMediaType
@@ -522,4 +522,4 @@ def _debugwrite(x):
if __name__ == "__main__":
import doctest
- doctest.testmod()
+ doctest.testmod()
Something went wrong with that request. Please try again.