aboutsummaryrefslogtreecommitdiffstats
path: root/djangorestframework/resources.py
diff options
context:
space:
mode:
authorTom Christie2012-01-21 18:33:34 +0000
committerTom Christie2012-01-21 18:33:34 +0000
commitdea4a45ec72d0bd3cfeeb9382f177eb2fc3b0e14 (patch)
tree99c9824ee53d6e57546eceb3551546cf72585c85 /djangorestframework/resources.py
parenta851294d052174b53531fdf90b22ddac8738e374 (diff)
downloaddjango-rest-framework-dea4a45ec72d0bd3cfeeb9382f177eb2fc3b0e14.tar.bz2
pep8/pyflakes cleanup
Diffstat (limited to 'djangorestframework/resources.py')
-rw-r--r--djangorestframework/resources.py34
1 files changed, 1 insertions, 33 deletions
diff --git a/djangorestframework/resources.py b/djangorestframework/resources.py
index 9a43c8af..cc338cc0 100644
--- a/djangorestframework/resources.py
+++ b/djangorestframework/resources.py
@@ -1,20 +1,11 @@
from django import forms
from django.core.urlresolvers import reverse, get_urlconf, get_resolver, NoReverseMatch
from django.db import models
-from django.db.models.query import QuerySet
-from django.db.models.fields.related import RelatedField
-from django.utils.encoding import smart_unicode
from djangorestframework.response import ErrorResponse
from djangorestframework.serializer import Serializer, _SkipField
from djangorestframework.utils import as_tuple
-import decimal
-import inspect
-import re
-
-
-
class BaseResource(Serializer):
"""
@@ -82,11 +73,10 @@ class FormResource(Resource):
"""
Flag to check for unknown fields when validating a form. If set to false and
we receive request data that is not expected by the form it raises an
- :exc:`response.ErrorResponse` with status code 400. If set to true, only
+ :exc:`response.ErrorResponse` with status code 400. If set to true, only
expected fields are validated.
"""
-
def validate_request(self, data, files=None):
"""
Given some content as input return some cleaned, validated content.
@@ -101,7 +91,6 @@ class FormResource(Resource):
"""
return self._validate(data, files)
-
def _validate(self, data, files, allowed_extra_fields=(), fake_data=None):
"""
Wrapped by validate to hide the extra flags that are used in the implementation.
@@ -187,7 +176,6 @@ class FormResource(Resource):
# Return HTTP 400 response (BAD REQUEST)
raise ErrorResponse(400, detail)
-
def get_form_class(self, method=None):
"""
Returns the form class used to validate this resource.
@@ -209,7 +197,6 @@ class FormResource(Resource):
return form
-
def get_bound_form(self, data=None, files=None, method=None):
"""
Given some content return a Django form bound to that content.
@@ -226,20 +213,6 @@ class FormResource(Resource):
return form()
-
-#class _RegisterModelResource(type):
-# """
-# Auto register new ModelResource classes into ``_model_to_resource``
-# """
-# def __new__(cls, name, bases, dct):
-# resource_cls = type.__new__(cls, name, bases, dct)
-# model_cls = dct.get('model', None)
-# if model_cls:
-# _model_to_resource[model_cls] = resource_cls
-# return resource_cls
-
-
-
class ModelResource(FormResource):
"""
Resource class that uses forms for validation and otherwise falls back to a model form if no form is set.
@@ -282,7 +255,6 @@ class ModelResource(FormResource):
The list of fields to exclude. This is only used if :attr:`fields` is not set.
"""
-
include = ('url',)
"""
The list of extra fields to include. This is only used if :attr:`fields` is not set.
@@ -298,7 +270,6 @@ class ModelResource(FormResource):
self.model = getattr(view, 'model', None) or self.model
-
def validate_request(self, data, files=None):
"""
Given some content as input return some cleaned, validated content.
@@ -315,7 +286,6 @@ class ModelResource(FormResource):
"""
return self._validate(data, files, allowed_extra_fields=self._property_fields_set)
-
def get_bound_form(self, data=None, files=None, method=None):
"""
Given some content return a ``Form`` instance bound to that content.
@@ -348,7 +318,6 @@ class ModelResource(FormResource):
return form()
-
def url(self, instance):
"""
Attempts to reverse resolve the url of the given model *instance* for this resource.
@@ -390,7 +359,6 @@ class ModelResource(FormResource):
pass
raise _SkipField
-
@property
def _model_fields_set(self):
"""