def get_response(self, request):
    'Returns an HttpResponse object for the given HttpRequest'
    from django.core import exceptions, urlresolvers
    from django.conf import settings
    try:
        urlconf = settings.ROOT_URLCONF
        urlresolvers.set_urlconf(urlconf)
        resolver = urlresolvers.RegexURLResolver('^/', urlconf)
        try:
            response = None
            for middleware_method in self._request_middleware:
                response = middleware_method(request)
                if response:
                    break
            if (response is None):
                if hasattr(request, 'urlconf'):
                    urlconf = request.urlconf
                    urlresolvers.set_urlconf(urlconf)
                    resolver = urlresolvers.RegexURLResolver('^/', urlconf)
                (callback, callback_args, callback_kwargs) = resolver.resolve(request.path_info)
                for middleware_method in self._view_middleware:
                    response = middleware_method(request, callback, callback_args, callback_kwargs)
                    if response:
                        break
            if (response is None):
                try:
                    response = callback(request, *callback_args, **callback_kwargs)
                except Exception as e:
                    for middleware_method in self._exception_middleware:
                        response = middleware_method(request, e)
                        if response:
                            break
                    if (response is None):
                        raise
            if (response is None):
                if isinstance(callback, types.FunctionType):
                    view_name = callback.__name__
                else:
                    view_name = (callback.__class__.__name__ + '.__call__')
                raise ValueError(("The view %s.%s didn't return an HttpResponse object." % (callback.__module__, view_name)))
            if (hasattr(response, 'render') and callable(response.render)):
                for middleware_method in self._template_response_middleware:
                    response = middleware_method(request, response)
                response = response.render()
        except http.Http404 as e:
            logger.warning('Not Found: %s', request.path, extra={'status_code': 404, 'request': request})
            if settings.DEBUG:
                from django.views import debug
                response = debug.technical_404_response(request, e)
            else:
                try:
                    (callback, param_dict) = resolver.resolve404()
                    response = callback(request, **param_dict)
                except:
                    signals.got_request_exception.send(sender=self.__class__, request=request)
                    response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
        except exceptions.PermissionDenied:
            logger.warning('Forbidden (Permission denied): %s', request.path, extra={'status_code': 403, 'request': request})
            try:
                (callback, param_dict) = resolver.resolve403()
                response = callback(request, **param_dict)
            except:
                signals.got_request_exception.send(sender=self.__class__, request=request)
                response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
        except SystemExit:
            raise
        except:
            signals.got_request_exception.send(sender=self.__class__, request=request)
            response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
    finally:
        urlresolvers.set_urlconf(None)
    try:
        for middleware_method in self._response_middleware:
            response = middleware_method(request, response)
        response = self.apply_response_fixes(request, response)
    except:
        signals.got_request_exception.send(sender=self.__class__, request=request)
        response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
    return response
Returns an HttpResponse object for the given HttpRequest
def get_response(self, request):
    
    from django.core import exceptions, urlresolvers
    from django.conf import settings
    try:
        urlconf = settings.ROOT_URLCONF
        urlresolvers.set_urlconf(urlconf)
        resolver = urlresolvers.RegexURLResolver('^/', urlconf)
        try:
            response = None
            for middleware_method in self._request_middleware:
                response = middleware_method(request)
                if response:
                    break
            if (response is None):
                if hasattr(request, 'urlconf'):
                    urlconf = request.urlconf
                    urlresolvers.set_urlconf(urlconf)
                    resolver = urlresolvers.RegexURLResolver('^/', urlconf)
                (callback, callback_args, callback_kwargs) = resolver.resolve(request.path_info)
                for middleware_method in self._view_middleware:
                    response = middleware_method(request, callback, callback_args, callback_kwargs)
                    if response:
                        break
            if (response is None):
                try:
                    response = callback(request, *callback_args, **callback_kwargs)
                except Exception as e:
                    for middleware_method in self._exception_middleware:
                        response = middleware_method(request, e)
                        if response:
                            break
                    if (response is None):
                        raise
            if (response is None):
                if isinstance(callback, types.FunctionType):
                    view_name = callback.__name__
                else:
                    view_name = (callback.__class__.__name__ + '.__call__')
                raise ValueError(("The view %s.%s didn't return an HttpResponse object." % (callback.__module__, view_name)))
            if (hasattr(response, 'render') and callable(response.render)):
                for middleware_method in self._template_response_middleware:
                    response = middleware_method(request, response)
                response = response.render()
        except http.Http404 as e:
            logger.warning('Not Found: %s', request.path, extra={'status_code': 404, 'request': request})
            if settings.DEBUG:
                from django.views import debug
                response = debug.technical_404_response(request, e)
            else:
                try:
                    (callback, param_dict) = resolver.resolve404()
                    response = callback(request, **param_dict)
                except:
                    signals.got_request_exception.send(sender=self.__class__, request=request)
                    response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
        except exceptions.PermissionDenied:
            logger.warning('Forbidden (Permission denied): %s', request.path, extra={'status_code': 403, 'request': request})
            try:
                (callback, param_dict) = resolver.resolve403()
                response = callback(request, **param_dict)
            except:
                signals.got_request_exception.send(sender=self.__class__, request=request)
                response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
        except SystemExit:
            raise
        except:
            signals.got_request_exception.send(sender=self.__class__, request=request)
            response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
    finally:
        urlresolvers.set_urlconf(None)
    try:
        for middleware_method in self._response_middleware:
            response = middleware_method(request, response)
        response = self.apply_response_fixes(request, response)
    except:
        signals.got_request_exception.send(sender=self.__class__, request=request)
        response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
    return response