diff options
| author | Tom Christie | 2012-09-14 22:42:29 +0100 |
|---|---|---|
| committer | Tom Christie | 2012-09-14 22:42:29 +0100 |
| commit | b3e29d9576f1b1b6d12f9abfeb4a06f669b45202 (patch) | |
| tree | d89770f15bdfa6b00e4a91e2a8d0a270106065b8 /djangorestframework/renderers.py | |
| parent | b7b8cd11b1aad3fcf4bad221d164bb55e0bf5859 (diff) | |
| download | django-rest-framework-b3e29d9576f1b1b6d12f9abfeb4a06f669b45202.tar.bz2 | |
Moved content negotiation out of response. Nicer exception handling now.
Diffstat (limited to 'djangorestframework/renderers.py')
| -rw-r--r-- | djangorestframework/renderers.py | 28 |
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): """ |
