diff options
| author | Tom Christie | 2011-04-11 16:38:00 +0100 |
|---|---|---|
| committer | Tom Christie | 2011-04-11 16:38:00 +0100 |
| commit | 349ffcaf5f03b55d8ffe92999814ba97da5ca870 (patch) | |
| tree | b12c6fd3504af09000d480a8f38c1b76d095afda /djangorestframework/response.py | |
| parent | a1ed565081779e3f50e9f0ff280a813a46f3613d (diff) | |
| download | django-rest-framework-349ffcaf5f03b55d8ffe92999814ba97da5ca870.tar.bz2 | |
Rename mixins into Mixin class, rename ResponseException to ErrorResponse, remove NoContent
Diffstat (limited to 'djangorestframework/response.py')
| -rw-r--r-- | djangorestframework/response.py | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/djangorestframework/response.py b/djangorestframework/response.py index 809e1754..545a5834 100644 --- a/djangorestframework/response.py +++ b/djangorestframework/response.py @@ -1,24 +1,16 @@ from django.core.handlers.wsgi import STATUS_CODE_TEXT -__all__ =['NoContent', 'Response', ] - - - -class NoContent(object): - """Used to indicate no body in http response. - (We cannot just use None, as that is a valid, serializable response object.) - - TODO: On reflection I'm going to get rid of this and just not support serialized 'None' responses. - """ - pass +__all__ =['Response', 'ErrorResponse'] +# TODO: remove raw_content/cleaned_content and just use content? class Response(object): - def __init__(self, status=200, content=NoContent, headers={}): + """An HttpResponse that may include content that hasn't yet been serialized.""" + def __init__(self, status=200, content=None, headers={}): self.status = status - 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.has_content_body = content is not None + self.raw_content = content # content prior to filtering + self.cleaned_content = content # content after filtering self.headers = headers @property @@ -28,6 +20,7 @@ class Response(object): return STATUS_CODE_TEXT.get(self.status, '') -class ResponseException(BaseException): - def __init__(self, status, content=NoContent, headers={}): +class ErrorResponse(BaseException): + """An exception representing an HttpResponse that should be returned immediatley.""" + def __init__(self, status, content=None, headers={}): self.response = Response(status, content=content, headers=headers) |
