aboutsummaryrefslogtreecommitdiffstats
path: root/djangorestframework/response.py
diff options
context:
space:
mode:
authortom christie tom@tomchristie.com2011-02-19 10:47:26 +0000
committertom christie tom@tomchristie.com2011-02-19 10:47:26 +0000
commit57b3a372f2122d022f9d6f43818e5fe9d318ce03 (patch)
treeeb667e2de5681d1886d5119b5d4092b12cd24524 /djangorestframework/response.py
parent805aa03ec1871f6a766d9052b348ddce9e9843c3 (diff)
downloaddjango-rest-framework-57b3a372f2122d022f9d6f43818e5fe9d318ce03.tar.bz2
Move status codes into seperate module
Diffstat (limited to 'djangorestframework/response.py')
-rw-r--r--djangorestframework/response.py108
1 files changed, 8 insertions, 100 deletions
diff --git a/djangorestframework/response.py b/djangorestframework/response.py
index e807eeb5..fb2e14a2 100644
--- a/djangorestframework/response.py
+++ b/djangorestframework/response.py
@@ -1,116 +1,24 @@
from django.core.handlers.wsgi import STATUS_CODE_TEXT
-__all__ =['status', 'NoContent', 'Response', ]
-
-
-class Status(object):
- """Descriptive HTTP status codes, for code readability.
- See RFC 2616 - Sec 10: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html"""
-
- # Verbose format (I prefer this as it's more explicit)
- HTTP_100_CONTINUE = 100
- HTTP_101_SWITCHING_PROTOCOLS = 101
- HTTP_200_OK = 200
- HTTP_201_CREATED = 201
- HTTP_202_ACCEPTED = 202
- HTTP_203_NON_AUTHORITATIVE_INFORMATION = 203
- HTTP_204_NO_CONTENT = 204
- HTTP_205_RESET_CONTENT = 205
- HTTP_206_PARTIAL_CONTENT = 206
- HTTP_300_MULTIPLE_CHOICES = 300
- HTTP_301_MOVED_PERMANENTLY = 301
- HTTP_302_FOUND = 302
- HTTP_303_SEE_OTHER = 303
- HTTP_304_NOT_MODIFIED = 304
- HTTP_305_USE_PROXY = 305
- HTTP_306_RESERVED = 306
- HTTP_307_TEMPORARY_REDIRECT = 307
- HTTP_400_BAD_REQUEST = 400
- HTTP_401_UNAUTHORIZED = 401
- HTTP_402_PAYMENT_REQUIRED = 402
- HTTP_403_FORBIDDEN = 403
- HTTP_404_NOT_FOUND = 404
- HTTP_405_METHOD_NOT_ALLOWED = 405
- HTTP_406_NOT_ACCEPTABLE = 406
- HTTP_407_PROXY_AUTHENTICATION_REQUIRED = 407
- HTTP_408_REQUEST_TIMEOUT = 408
- HTTP_409_CONFLICT = 409
- HTTP_410_GONE = 410
- HTTP_411_LENGTH_REQUIRED = 411
- HTTP_412_PRECONDITION_FAILED = 412
- HTTP_413_REQUEST_ENTITY_TOO_LARGE = 413
- HTTP_414_REQUEST_URI_TOO_LONG = 414
- HTTP_415_UNSUPPORTED_MEDIA_TYPE = 415
- HTTP_416_REQUESTED_RANGE_NOT_SATISFIABLE = 416
- HTTP_417_EXPECTATION_FAILED = 417
- HTTP_500_INTERNAL_SERVER_ERROR = 500
- HTTP_501_NOT_IMPLEMENTED = 501
- HTTP_502_BAD_GATEWAY = 502
- HTTP_503_SERVICE_UNAVAILABLE = 503
- HTTP_504_GATEWAY_TIMEOUT = 504
- HTTP_505_HTTP_VERSION_NOT_SUPPORTED = 505
-
- # Short format
- CONTINUE = 100
- SWITCHING_PROTOCOLS = 101
- OK = 200
- CREATED = 201
- ACCEPTED = 202
- NON_AUTHORITATIVE_INFORMATION = 203
- NO_CONTENT = 204
- RESET_CONTENT = 205
- PARTIAL_CONTENT = 206
- MULTIPLE_CHOICES = 300
- MOVED_PERMANENTLY = 301
- FOUND = 302
- SEE_OTHER = 303
- NOT_MODIFIED = 304
- USE_PROXY = 305
- RESERVED = 306
- TEMPORARY_REDIRECT = 307
- BAD_REQUEST = 400
- UNAUTHORIZED = 401
- PAYMENT_REQUIRED = 402
- FORBIDDEN = 403
- NOT_FOUND = 404
- METHOD_NOT_ALLOWED = 405
- NOT_ACCEPTABLE = 406
- PROXY_AUTHENTICATION_REQUIRED = 407
- REQUEST_TIMEOUT = 408
- CONFLICT = 409
- GONE = 410
- LENGTH_REQUIRED = 411
- PRECONDITION_FAILED = 412
- REQUEST_ENTITY_TOO_LARGE = 413
- REQUEST_URI_TOO_LONG = 414
- UNSUPPORTED_MEDIA_TYPE = 415
- REQUESTED_RANGE_NOT_SATISFIABLE = 416
- EXPECTATION_FAILED = 417
- INTERNAL_SERVER_ERROR = 500
- NOT_IMPLEMENTED = 501
- BAD_GATEWAY = 502
- SERVICE_UNAVAILABLE = 503
- GATEWAY_TIMEOUT = 504
- HTTP_VERSION_NOT_SUPPORTED = 505
+__all__ =['NoContent', 'Response', ]
-# This is simply stylistic, I think 'status.HTTP_200_OK' reads nicely.
-status = Status()
-
-
class NoContent(object):
"""Used to indicate no body in http response.
- (We cannot just use None, as that is a valid, serializable response object.)"""
+ (We cannot just use None, as that is a valid, serializable response object.)
+
+ TODO: On relflection I'm going to get rid of this and just not support serailized 'None' responses.
+ """
pass
class Response(object):
def __init__(self, status=200, content=NoContent, headers={}):
self.status = status
- self.has_content_body = not content is NoContent
- self.raw_content = content # content prior to filtering
- self.cleaned_content = content # content after filtering
+ self.has_content_body = not content is NoContent # TODO: remove and just use content
+ self.raw_content = content # content prior to filtering - TODO: remove and just use content
+ self.cleaned_content = content # content after filtering TODO: remove and just use content
self.headers = headers
@property