summaryrefslogtreecommitdiff
path: root/src/mailman/rest/helpers.py
diff options
context:
space:
mode:
authorBarry Warsaw2014-08-14 14:23:14 -0400
committerBarry Warsaw2014-08-14 14:23:14 -0400
commit0afbc268937456769714971a7f1f00141d21f223 (patch)
tree55d941d6a7048405da86216d86d386faae2b16c0 /src/mailman/rest/helpers.py
parent4236657a07af91b1a247ca3fecc3838a875d127f (diff)
downloadmailman-0afbc268937456769714971a7f1f00141d21f223.tar.gz
mailman-0afbc268937456769714971a7f1f00141d21f223.tar.zst
mailman-0afbc268937456769714971a7f1f00141d21f223.zip
Diffstat (limited to 'src/mailman/rest/helpers.py')
-rw-r--r--src/mailman/rest/helpers.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/mailman/rest/helpers.py b/src/mailman/rest/helpers.py
index 74c66958d..acc5106be 100644
--- a/src/mailman/rest/helpers.py
+++ b/src/mailman/rest/helpers.py
@@ -25,8 +25,15 @@ __all__ = [
'ChildError',
'GetterSetter',
'NotFound',
+ 'bad_request',
'child',
+ 'conflict',
+ 'created',
'etag',
+ 'forbidden',
+ 'no_content',
+ 'not_found',
+ 'okay',
'path_to',
]
@@ -272,3 +279,42 @@ class BadRequest(ChildError):
class NotFound(ChildError):
def __init__(self):
super(NotFound, self).__init__(falcon.HTTP_404)
+
+
+def okay(response, body=None):
+ response.status = falcon.HTTP_200
+ if body is not None:
+ response.body = body
+
+
+def no_content(response):
+ response.status = falcon.HTTP_204
+
+
+def not_found(response, body=b'404 Not Found'):
+ response.status = falcon.HTTP_404
+ if body is not None:
+ response.body = body
+
+
+def bad_request(response, body='400 Bad Request'):
+ response.status = falcon.HTTP_400
+ if body is not None:
+ response.body = body
+
+
+def created(response, location):
+ response.status = falcon.HTTP_201
+ response.location = location
+
+
+def conflict(response, body=b'409 Conflict'):
+ response.status = falcon.HTTP_409
+ if body is not None:
+ response.body = body
+
+
+def forbidden(response, body=b'403 Forbidden'):
+ response.status = falcon.HTTP_403
+ if body is not None:
+ response.body = body