From 7ee1bbecc652ed3237182399bd644c1d42dff2db Mon Sep 17 00:00:00 2001 From: Jens Alm Date: Sat, 2 Jul 2011 18:38:55 +0200 Subject: [PATCH 1/3] Set default renderers for views when yaml is not installed Will use the renderer.DEFAULT_RENDERERS dict for determining available renderers in views.View to avoid a nonexistent renderer when yaml is not installed. Duplicates the behavior in parsers.DEFAULT_PARSERS --- djangorestframework/parsers.py | 6 ++++++ djangorestframework/views.py | 12 ++---------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/djangorestframework/parsers.py b/djangorestframework/parsers.py index 5f19c521b..cfe8ec9ed 100644 --- a/djangorestframework/parsers.py +++ b/djangorestframework/parsers.py @@ -167,3 +167,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,) \ No newline at end of file diff --git a/djangorestframework/views.py b/djangorestframework/views.py index 757d89db4..aedc7427b 100644 --- a/djangorestframework/views.py +++ b/djangorestframework/views.py @@ -40,20 +40,12 @@ class View(ResourceMixin, RequestMixin, ResponseMixin, AuthMixin, DjangoView): """ List of renderers the resource can serialize the response with, ordered by preference. """ - renderers = ( renderers.JSONRenderer, - renderers.DocumentingHTMLRenderer, - renderers.DocumentingXHTMLRenderer, - renderers.DocumentingPlainTextRenderer, - renderers.XMLRenderer, - renderers.YAMLRenderer ) + renderers = renderers.DEFAULT_RENDERERS """ 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. """ From bcddc6f09a9bdb595e913c8de32228474365c74f Mon Sep 17 00:00:00 2001 From: Jens Alm Date: Sat, 2 Jul 2011 18:39:27 +0200 Subject: [PATCH 2/3] gitignore --- .gitignore | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.gitignore b/.gitignore index 4947943af..5b9bf1bb4 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,21 @@ MANIFEST .coverage .tox .DS_Store + +.idea/workspace.xml + +.idea/vcs.xml + +.idea/modules.xml + +.idea/misc.xml + +.idea/encodings.xml + +.idea/django-rest-framework.iml + +.idea/.name + +.gitignore + +.gitignore From 3900abd37f69867f8624dd98529702229e9c1adf Mon Sep 17 00:00:00 2001 From: Jens Alm Date: Sat, 2 Jul 2011 18:40:25 +0200 Subject: [PATCH 3/3] .gitignore --- .gitignore | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 5b9bf1bb4..bec1e7746 100644 --- a/.gitignore +++ b/.gitignore @@ -34,8 +34,4 @@ MANIFEST .idea/django-rest-framework.iml -.idea/.name - -.gitignore - -.gitignore +.idea/.name \ No newline at end of file