aboutsummaryrefslogtreecommitdiffstats
path: root/djangorestframework/renderers.py
diff options
context:
space:
mode:
authorTom Christie2012-09-16 14:02:18 -0700
committerTom Christie2012-09-16 14:02:18 -0700
commit549ebdc1c67c20bdff39a2f4a59012dd010213a1 (patch)
treeef7b3626e602ecaa1761cb4e780501f0b8db9463 /djangorestframework/renderers.py
parentb7b8cd11b1aad3fcf4bad221d164bb55e0bf5859 (diff)
parentd8ede0355c32455989ca5f955d555ffaf827b296 (diff)
downloaddjango-rest-framework-549ebdc1c67c20bdff39a2f4a59012dd010213a1.tar.bz2
Merge pull request #263 from tomchristie/decouple-conneg
Content negotiation logic out of response and into View
Diffstat (limited to 'djangorestframework/renderers.py')
-rw-r--r--djangorestframework/renderers.py28
1 files changed, 11 insertions, 17 deletions
diff --git a/djangorestframework/renderers.py b/djangorestframework/renderers.py
index 26e8cba1..729f8111 100644
--- a/djangorestframework/renderers.py
+++ b/djangorestframework/renderers.py
@@ -48,28 +48,22 @@ class BaseRenderer(object):
def __init__(self, view=None):
self.view = view
- def can_handle_response(self, accept):
+ def can_handle_format(self, format):
+ return format == self.format
+
+ def can_handle_media_type(self, media_type):
"""
- Returns :const:`True` if this renderer is able to deal with the given
- *accept* media type.
+ Returns `True` if this renderer is able to deal with the given
+ media type.
- The default implementation for this function is to check the *accept*
- argument against the :attr:`media_type` attribute set on the class to see if
+ The default implementation for this function is to check the media type
+ argument against the media_type attribute set on the class to see if
they match.
- This may be overridden to provide for other behavior, but typically you'll
- instead want to just set the :attr:`media_type` attribute on the class.
+ This may be overridden to provide for other behavior, but typically
+ you'll instead want to just set the `media_type` attribute on the class.
"""
- # TODO: format overriding must go out of here
- format = None
- if self.view is not None:
- format = self.view.kwargs.get(self._FORMAT_QUERY_PARAM, None)
- if format is None and self.view is not None:
- format = self.view.request.GET.get(self._FORMAT_QUERY_PARAM, None)
-
- if format is not None:
- return format == self.format
- return media_type_matches(self.media_type, accept)
+ return media_type_matches(self.media_type, media_type)
def render(self, obj=None, media_type=None):
"""