diff options
| author | Tom Christie | 2011-05-10 16:01:58 +0100 |
|---|---|---|
| committer | Tom Christie | 2011-05-10 16:01:58 +0100 |
| commit | 4d126796752cc3c79a24fd9caed49da6c525096f (patch) | |
| tree | 117148c29b0a0f8ca4bbfb299a613b2dbabe8259 /djangorestframework/response.py | |
| parent | a2575c1191104df024b41c58825b9a24d4c4ae2d (diff) | |
| download | django-rest-framework-4d126796752cc3c79a24fd9caed49da6c525096f.tar.bz2 | |
More tests, getting new serialization into resource
Diffstat (limited to 'djangorestframework/response.py')
| -rw-r--r-- | djangorestframework/response.py | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/djangorestframework/response.py b/djangorestframework/response.py index 9b3c5851..72bc16c8 100644 --- a/djangorestframework/response.py +++ b/djangorestframework/response.py @@ -1,11 +1,14 @@ from django.core.handlers.wsgi import STATUS_CODE_TEXT -__all__ =['Response', 'ErrorResponse'] +__all__ = ('Response', 'ErrorResponse') # TODO: remove raw_content/cleaned_content and just use content? class Response(object): - """An HttpResponse that may include content that hasn't yet been serialized.""" + """ + 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 = content is not None @@ -15,12 +18,18 @@ class Response(object): @property def status_text(self): - """Return reason text corresponding to our HTTP response status code. - Provided for convenience.""" + """ + Return reason text corresponding to our HTTP response status code. + Provided for convenience. + """ return STATUS_CODE_TEXT.get(self.status, '') class ErrorResponse(BaseException): - """An exception representing an HttpResponse that should be returned immediately.""" + """ + An exception representing an Response that should be returned immediately. + Any content should be serialized as-is, without being filtered. + """ + def __init__(self, status, content=None, headers={}): self.response = Response(status, content=content, headers=headers) |
