From 42cda616dae6201956f7de4796be7fc0e4e7a848 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Piquemal?= Date: Mon, 9 Jan 2012 20:11:00 +0200 Subject: [PATCH] made the BaseResource more interface-y (no implemented method) + added 'queryset' parameter for ModelListView --- djangorestframework/resources.py | 9 ++++++--- djangorestframework/views.py | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/djangorestframework/resources.py b/djangorestframework/resources.py index 192d134cb..dc540c6b4 100644 --- a/djangorestframework/resources.py +++ b/djangorestframework/resources.py @@ -7,7 +7,7 @@ from djangorestframework.response import ErrorResponse from djangorestframework.serializer import Serializer, _SkipField -class BaseResource(Serializer): +class BaseResource(object): """ Base class for all Resource classes, which simply defines the interface they provide. @@ -31,7 +31,7 @@ class BaseResource(Serializer): Typically raises a :exc:`response.ErrorResponse` with status code 400 (Bad Request) on failure. """ - return data + raise NotImplementedError() def retrieve(self, *args, **kwargs): raise NotImplementedError() @@ -52,7 +52,7 @@ class BaseResource(Serializer): return not self.instance is None -class Resource(BaseResource): +class Resource(Serializer, BaseResource): """ A Resource determines how a python object maps to some serializable data. Objects that a resource can act on include plain Python object instances, @@ -74,6 +74,9 @@ class Resource(BaseResource): # you should explicitly set the fields attribute on your class. fields = None + def deserialize(self, data, files=None): + return data + class FormResource(Resource): """ diff --git a/djangorestframework/views.py b/djangorestframework/views.py index f93356d79..03347266b 100644 --- a/djangorestframework/views.py +++ b/djangorestframework/views.py @@ -201,10 +201,11 @@ class ListModelView(ListResourceMixin, ModelView): A view which provides default operations for list, against a model in the database. """ + queryset = None _suffix = 'List' -class ListOrCreateModelView(PostResourceMixin, ListResourceMixin, ModelView): +class ListOrCreateModelView(PostResourceMixin, ListModelView, ModelView): """ A view which provides default operations for list and create, against a model in the database.