aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Christie2011-07-02 10:36:26 -0700
committerTom Christie2011-07-02 10:36:26 -0700
commitf43f20bd3a6e345345f0ba52460f43a66d610adc (patch)
tree1bbb7b26fb0d8b530743615af15b32149a35e98b
parent1885012d61c7ba78e78648ef2bff89e4337c0407 (diff)
parent3e0a978dd97a55a5db072584a2bba639ed790b82 (diff)
downloaddjango-rest-framework-f43f20bd3a6e345345f0ba52460f43a66d610adc.tar.bz2
Merge pull request #40 from ulmus/master
Added parsers.DEFAULT_PARSERS
-rw-r--r--.gitignore1
-rw-r--r--djangorestframework/parsers.py9
-rw-r--r--djangorestframework/views.py4
3 files changed, 10 insertions, 4 deletions
diff --git a/.gitignore b/.gitignore
index 4947943a..312b28df 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,3 +21,4 @@ MANIFEST
.coverage
.tox
.DS_Store
+.idea/* \ No newline at end of file
diff --git a/djangorestframework/parsers.py b/djangorestframework/parsers.py
index 5f19c521..41f15aa3 100644
--- a/djangorestframework/parsers.py
+++ b/djangorestframework/parsers.py
@@ -108,7 +108,8 @@ if yaml:
except ValueError, exc:
raise ErrorResponse(status.HTTP_400_BAD_REQUEST,
{'detail': 'YAML parse error - %s' % unicode(exc)})
-
+else:
+ YAMLParser = None
class PlainTextParser(BaseParser):
"""
@@ -167,3 +168,9 @@ class MultiPartParser(BaseParser):
{'detail': 'multipart parse error - %s' % unicode(exc)})
return django_parser.parse()
+DEFAULT_PARSERS = ( JSONParser,
+ FormParser,
+ MultiPartParser )
+
+if YAMLParser:
+ DEFAULT_PARSERS += (YAMLParser,)
diff --git a/djangorestframework/views.py b/djangorestframework/views.py
index eea3b97a..c25bb88f 100644
--- a/djangorestframework/views.py
+++ b/djangorestframework/views.py
@@ -44,9 +44,7 @@ class View(ResourceMixin, RequestMixin, ResponseMixin, AuthMixin, DjangoView):
"""
List of parsers the resource can parse the request with.
"""
- parsers = ( parsers.JSONParser,
- parsers.FormParser,
- parsers.MultiPartParser )
+ parsers = parsers.DEFAULT_PARSERS
"""
List of all authenticating methods to attempt.