示例#1
0
    def __call__(self, request, *args, **kwargs):

        request_method = request.method.upper()
        if request_method not in self.permitted_methods:
            return HttpResponseNotAllowed(self.permitted_methods)

        try:
            return getattr(self, METHOD_MAPPING[request_method])(request, *args, **kwargs)
        except Http404:
            raise
        except Http403:
            return HttpResponseForbidden()
        except HttpBadCredentials:
            return build_auth_error_response(request, "Bad credentials")
示例#2
0
    def __call__(self, request, *args, **kwargs):

        request_method = request.method.upper()
        if request_method not in self.permitted_methods:
            return HttpResponseNotAllowed(self.permitted_methods)

        try:
            return getattr(self,
                           METHOD_MAPPING[request_method])(request, *args,
                                                           **kwargs)
        except Http404:
            raise
        except Http403:
            return HttpResponseForbidden()
        except HttpBadCredentials as e:
            return build_auth_error_response(request, e.message, e.error_info)
        except ErrorResponse as e:
            return e.response
示例#3
0
    def __call__(self, request, *args, **kwargs):

        request_method = request.method.upper()
        if request_method not in self.permitted_methods:
            return HttpResponseNotAllowed(self.permitted_methods)

        try:
            response = getattr(self, METHOD_MAPPING[request_method])(request, *args, **kwargs)
        except (Http404, PermissionDenied):
            raise
        except HttpBadCredentials as e:
            return build_auth_error_response(request, e.message, e.error_info)
        except ErrorResponse as e:
            return e.response

        if request_method in ("HEAD", "GET"):
            patch_cache_headers(response)

        return response
示例#4
0
    def __call__(self, request, *args, **kwargs):

        request_method = request.method.upper()
        if request_method not in self.permitted_methods:
            return HttpResponseNotAllowed(self.permitted_methods)

        try:
            response = getattr(self,
                               METHOD_MAPPING[request_method])(request, *args,
                                                               **kwargs)
        except (Http404, PermissionDenied):
            raise
        except HttpBadCredentials as e:
            return build_auth_error_response(request, e.message, e.error_info)
        except ErrorResponse as e:
            return e.response

        if request_method in ('HEAD', 'GET'):
            patch_cache_headers(response)

        return response