made the BaseResource more interface-y (no implemented method) + added 'queryset' parameter for ModelListView

This commit is contained in:
Sébastien Piquemal 2012-01-09 20:11:00 +02:00
parent 89e1cae28e
commit 42cda616da
2 changed files with 8 additions and 4 deletions

View File

@ -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):
"""

View File

@ -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.