Permalink
Browse files

Merge pull request #82 from fredludlow/master

Python 2.4 Compatibility Fixes
  • Loading branch information...
2 parents 0cca746 + c07c0bb commit edc3ef160fcd3e579e6a1b0c66a51908e2f09178 @aaronsw aaronsw committed Jul 16, 2011
Showing with 55 additions and 8 deletions.
  1. +5 −2 web/application.py
  2. +50 −6 web/webapi.py
View
@@ -636,9 +636,12 @@ class Reloader:
if so, reloads them.
"""
- SUFFIX = '$py.class' if sys.platform.startswith('java') else '.pyc'
"""File suffix of compiled modules."""
-
+ if sys.platform.startswith('java'):
+ SUFFIX = '$py.class'
+ else:
+ SUFFIX = '.pyc'
+
def __init__(self):
self.mtimes = {}
View
@@ -129,6 +129,26 @@ def __init__(self):
badrequest = BadRequest
+class Unauthorized(HTTPError):
+ """`401 Unauthorized` error."""
+ message = "unauthorized"
+ def __init__(self):
+ status = "401 Unauthorized"
+ headers = {'Content-Type': 'text/html'}
+ HTTPError.__init__(self, status, headers, self.message)
+
+unauthorized = Unauthorized
+
+class Forbidden(HTTPError):
+ """`403 Forbidden` error."""
+ message = "forbidden"
+ def __init__(self):
+ status = "403 Forbidden"
+ headers = {'Content-Type': 'text/html'}
+ HTTPError.__init__(self, status, headers, self.message)
+
+forbidden = Forbidden
+
class _NotFound(HTTPError):
"""`404 Not Found` error."""
message = "not found"
@@ -149,12 +169,6 @@ def NotFound(message=None):
notfound = NotFound
-unauthorized = Unauthorized = _status_code("401 Unauthorized")
-forbidden = Forbidden = _status_code("403 Forbidden")
-notacceptable = NotAcceptable = _status_code("406 Not Acceptable")
-conflict = Conflict = _status_code("409 Conflict")
-preconditionfailed = PreconditionFailed = _status_code("412 Precondition Failed")
-
class NoMethod(HTTPError):
"""A `405 Method Not Allowed` error."""
def __init__(self, cls=None):
@@ -172,6 +186,26 @@ def __init__(self, cls=None):
nomethod = NoMethod
+class NotAcceptable(HTTPError):
+ """`406 Not Acceptable` error."""
+ message = "not acceptable"
+ def __init__(self):
+ status = "406 Not Acceptable"
+ headers = {'Content-Type': 'text/html'}
+ HTTPError.__init__(self, status, headers, self.message)
+
+notacceptable = NotAcceptable
+
+class Conflict(HTTPError):
+ """`409 Conflict` error."""
+ message = "conflict"
+ def __init__(self):
+ status = "409 Conflict"
+ headers = {'Content-Type': 'text/html'}
+ HTTPError.__init__(self, status, headers, self.message)
+
+conflict = Conflict
+
class Gone(HTTPError):
"""`410 Gone` error."""
message = "gone"
@@ -182,6 +216,16 @@ def __init__(self):
gone = Gone
+class PreconditionFailed(HTTPError):
+ """`412 Precondition Failed` error."""
+ message = "precondition failed"
+ def __init__(self):
+ status = "412 Precondition Failed"
+ headers = {'Content-Type': 'text/html'}
+ HTTPError.__init__(self, status, headers, self.message)
+
+preconditionfailed = PreconditionFailed
+
class _InternalError(HTTPError):
"""500 Internal Server Error`."""
message = "internal server error"

0 comments on commit edc3ef1

Please sign in to comment.