Merge pull request #40 from ulmus/master

Added parsers.DEFAULT_PARSERS
This commit is contained in:
Tom Christie 2011-07-02 10:36:26 -07:00
commit f43f20bd3a
3 changed files with 10 additions and 4 deletions

1
.gitignore vendored
View File

@ -21,3 +21,4 @@ MANIFEST
.coverage .coverage
.tox .tox
.DS_Store .DS_Store
.idea/*

View File

@ -108,7 +108,8 @@ if yaml:
except ValueError, exc: except ValueError, exc:
raise ErrorResponse(status.HTTP_400_BAD_REQUEST, raise ErrorResponse(status.HTTP_400_BAD_REQUEST,
{'detail': 'YAML parse error - %s' % unicode(exc)}) {'detail': 'YAML parse error - %s' % unicode(exc)})
else:
YAMLParser = None
class PlainTextParser(BaseParser): class PlainTextParser(BaseParser):
""" """
@ -167,3 +168,9 @@ class MultiPartParser(BaseParser):
{'detail': 'multipart parse error - %s' % unicode(exc)}) {'detail': 'multipart parse error - %s' % unicode(exc)})
return django_parser.parse() return django_parser.parse()
DEFAULT_PARSERS = ( JSONParser,
FormParser,
MultiPartParser )
if YAMLParser:
DEFAULT_PARSERS += (YAMLParser,)

View File

@ -44,9 +44,7 @@ class View(ResourceMixin, RequestMixin, ResponseMixin, AuthMixin, DjangoView):
""" """
List of parsers the resource can parse the request with. List of parsers the resource can parse the request with.
""" """
parsers = ( parsers.JSONParser, parsers = parsers.DEFAULT_PARSERS
parsers.FormParser,
parsers.MultiPartParser )
""" """
List of all authenticating methods to attempt. List of all authenticating methods to attempt.