diff options
| author | Tom Christie | 2011-01-12 12:34:57 +0000 |
|---|---|---|
| committer | Tom Christie | 2011-01-12 12:34:57 +0000 |
| commit | 5557dfb54c8aeb35a781760fc2fb8334e53e98ea (patch) | |
| tree | 448ae6f08b09463ec1b7d8fc6e58a7530c446c35 /src/rest/parsers.py | |
| parent | 42825e44e14ca89ba97dd5c144f9f078fa762f1e (diff) | |
| download | django-rest-framework-5557dfb54c8aeb35a781760fc2fb8334e53e98ea.tar.bz2 | |
Various cleanups
Diffstat (limited to 'src/rest/parsers.py')
| -rw-r--r-- | src/rest/parsers.py | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/src/rest/parsers.py b/src/rest/parsers.py index 85b0e51f..73073243 100644 --- a/src/rest/parsers.py +++ b/src/rest/parsers.py @@ -1,9 +1,8 @@ import json class BaseParser(object): - def __init__(self, resource, request): + def __init__(self, resource): self.resource = resource - self.request = request def parse(self, input): return {} @@ -20,9 +19,9 @@ class FormParser(BaseParser): """The default parser for form data. Return a dict containing a single value for each non-reserved parameter """ - def __init__(self, resource, request): + def __init__(self, resource): - if request.method == 'PUT': + if resource.request.method == 'PUT': # Fix from piston to force Django to give PUT requests the same # form processing that POST requests get... # @@ -36,22 +35,22 @@ class FormParser(BaseParser): # the first time _load_post_and_files is called (both by wsgi.py and # modpython.py). If it's set, the request has to be 'reset' to redo # the query value parsing in POST mode. - if hasattr(request, '_post'): + if hasattr(resource.request, '_post'): del request._post del request._files try: - request.method = "POST" - request._load_post_and_files() - request.method = "PUT" + resource.request.method = "POST" + resource.request._load_post_and_files() + resource.request.method = "PUT" except AttributeError: - request.META['REQUEST_METHOD'] = 'POST' - request._load_post_and_files() - request.META['REQUEST_METHOD'] = 'PUT' + resource.request.META['REQUEST_METHOD'] = 'POST' + resource.request._load_post_and_files() + resource.request.META['REQUEST_METHOD'] = 'PUT' # self.data = {} - for (key, val) in request.POST.items(): + for (key, val) in resource.request.POST.items(): if key not in resource.RESERVED_PARAMS: self.data[key] = val |
