diff options
Diffstat (limited to 'djangorestframework')
| -rw-r--r-- | djangorestframework/authenticators.py | 8 | ||||
| -rw-r--r-- | djangorestframework/modelresource.py | 4 | ||||
| -rw-r--r-- | djangorestframework/resource.py | 8 | ||||
| -rw-r--r-- | djangorestframework/tests/authentication.py | 2 |
4 files changed, 17 insertions, 5 deletions
diff --git a/djangorestframework/authenticators.py b/djangorestframework/authenticators.py index e6f51dd5..19181b7d 100644 --- a/djangorestframework/authenticators.py +++ b/djangorestframework/authenticators.py @@ -73,4 +73,10 @@ class UserLoggedInAuthenticator(BaseAuthenticator): if resp is None: # csrf passed return request.user return None - + + +#class DigestAuthentication(BaseAuthentication): +# pass +# +#class OAuthAuthentication(BaseAuthentication): +# pass diff --git a/djangorestframework/modelresource.py b/djangorestframework/modelresource.py index a91c79ee..1afd7fa0 100644 --- a/djangorestframework/modelresource.py +++ b/djangorestframework/modelresource.py @@ -416,7 +416,7 @@ class RootModelResource(ModelResource): queryset = self.queryset if self.queryset else self.model.objects.all() return queryset.filter(**kwargs) - put = delete = http_method_not_allowed + put = delete = None class QueryModelResource(ModelResource): """Resource with default operations for list. @@ -428,4 +428,4 @@ class QueryModelResource(ModelResource): queryset = self.queryset if self.queryset else self.model.objects.all() return queryset.filer(**kwargs) - post = put = delete = http_method_not_allowed
\ No newline at end of file + post = put = delete = None
\ No newline at end of file diff --git a/djangorestframework/resource.py b/djangorestframework/resource.py index 65aa09c6..fbf51cfc 100644 --- a/djangorestframework/resource.py +++ b/djangorestframework/resource.py @@ -41,7 +41,7 @@ class Resource(RequestMixin, ResponseMixin, AuthMixin, View): authenticators.BasicAuthenticator ) # List of all permissions required to access the resource - permissions = ( permissions.DeleteMePermission, ) + permissions = () # Optional form for input validation and presentation of HTML formatted responses. form = None @@ -54,7 +54,7 @@ class Resource(RequestMixin, ResponseMixin, AuthMixin, View): @property def allowed_methods(self): - return [method.upper() for method in self.http_method_names if hasattr(self, method)] + return [method.upper() for method in self.http_method_names if getattr(self, method, None)] def http_method_not_allowed(self, request, *args, **kwargs): """Return an HTTP 405 error if an operation is called which does not have a handler method.""" @@ -96,6 +96,9 @@ class Resource(RequestMixin, ResponseMixin, AuthMixin, View): # Get the appropriate handler method if self.method.lower() in self.http_method_names: handler = getattr(self, self.method.lower(), self.http_method_not_allowed) + # If a previously defined method has been disabled + if handler is None: + handler = self.http_method_not_allowed else: handler = self.http_method_not_allowed @@ -125,3 +128,4 @@ class Resource(RequestMixin, ResponseMixin, AuthMixin, View): return self.emit(response) + diff --git a/djangorestframework/tests/authentication.py b/djangorestframework/tests/authentication.py index 72300506..f2c249a6 100644 --- a/djangorestframework/tests/authentication.py +++ b/djangorestframework/tests/authentication.py @@ -7,11 +7,13 @@ from django.utils import simplejson as json from djangorestframework.compat import RequestFactory from djangorestframework.resource import Resource +from djangorestframework import permissions import base64 class MockResource(Resource): + permissions = ( permissions.IsAuthenticated, ) def post(self, request): return {'a':1, 'b':2, 'c':3} |
