diff options
| author | Tom Christie | 2012-10-15 13:27:50 +0100 |
|---|---|---|
| committer | Tom Christie | 2012-10-15 13:27:50 +0100 |
| commit | 9c1fba3483b7e81da0744464dcf23a5f12711de2 (patch) | |
| tree | d9370dc9fb9d2fea65192bf5ce4d7fb594d3ad0c /rest_framework/views.py | |
| parent | e88ca9637bd4f49659dd80ca7afd0f38adf07746 (diff) | |
| download | django-rest-framework-9c1fba3483b7e81da0744464dcf23a5f12711de2.tar.bz2 | |
Tweak parsers to take parser_context
Diffstat (limited to 'rest_framework/views.py')
| -rw-r--r-- | rest_framework/views.py | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/rest_framework/views.py b/rest_framework/views.py index b3f36085..92d4445f 100644 --- a/rest_framework/views.py +++ b/rest_framework/views.py @@ -1,8 +1,5 @@ """ -The :mod:`views` module provides the Views you will most probably -be subclassing in your implementation. - -By setting or modifying class attributes on your view, you change it's predefined behaviour. +Provides an APIView class that is used as the base of all class-based views. """ import re @@ -159,9 +156,19 @@ class APIView(View): """ raise exceptions.Throttled(wait) + def get_parser_context(self, request): + """ + Returns a dict that is passed through to Parser.parse_stream(), + as the `parser_context` keyword argument. + """ + return { + 'upload_handlers': request.upload_handlers, + 'meta': request.META, + } + def get_renderer_context(self): """ - Returns a dict that is passed through to the Renderer.render(), + Returns a dict that is passed through to Renderer.render(), as the `renderer_context` keyword argument. """ # Note: Additionally 'response' will also be set on the context, @@ -253,10 +260,13 @@ class APIView(View): """ Returns the initial request object. """ + parser_context = self.get_parser_context(request) + return Request(request, parsers=self.get_parsers(), authenticators=self.get_authenticators(), - negotiator=self.get_content_negotiator()) + negotiator=self.get_content_negotiator(), + parser_context=parser_context) def initial(self, request, *args, **kwargs): """ |
