From cb9fb6ef2f9ac38c4f1c3946252a542b1f3f15d7 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Mon, 11 Apr 2011 13:45:38 +0100 Subject: Refactoring of authentication/permissions --- djangorestframework/resource.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'djangorestframework/resource.py') diff --git a/djangorestframework/resource.py b/djangorestframework/resource.py index 6ec22073..e6290363 100644 --- a/djangorestframework/resource.py +++ b/djangorestframework/resource.py @@ -6,7 +6,7 @@ from djangorestframework.emitters import EmitterMixin from djangorestframework.authenticators import AuthenticatorMixin from djangorestframework.validators import FormValidatorMixin from djangorestframework.response import Response, ResponseException -from djangorestframework.request import RequestMixin +from djangorestframework.request import RequestMixin, AuthMixin from djangorestframework import emitters, parsers, authenticators, status @@ -18,7 +18,7 @@ from djangorestframework import emitters, parsers, authenticators, status __all__ = ['Resource'] -class Resource(EmitterMixin, AuthenticatorMixin, FormValidatorMixin, RequestMixin, View): +class Resource(EmitterMixin, AuthMixin, FormValidatorMixin, RequestMixin, View): """Handles incoming requests and maps them to REST operations, performing authentication, input deserialization, input validation, output serialization.""" @@ -139,7 +139,7 @@ class Resource(EmitterMixin, AuthenticatorMixin, FormValidatorMixin, RequestMixi # Typically the context will be a user, or None if this is an anonymous request, # but it could potentially be more complex (eg the context of a request key which # has been signed against a particular set of permissions) - auth_context = self.authenticate(request) + auth_context = self.auth # If using a form POST with '_method'/'_content'/'_content_type' overrides, then alter # self.method, self.content_type, self.CONTENT appropriately. @@ -173,6 +173,10 @@ class Resource(EmitterMixin, AuthenticatorMixin, FormValidatorMixin, RequestMixi except ResponseException, exc: response = exc.response + + except: + import traceback + traceback.print_exc() # Always add these headers. # -- cgit v1.2.3