'Returns an HttpResponse object for the given HttpRequest'

def get_response(self, request):

    try:
        urlconf = settings.ROOT_URLCONF
        urlresolvers.set_urlconf(urlconf)
        resolver = urlresolvers.RegexURLResolver(u'^/', 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, u'urlconf'):
                    urlconf = request.urlconf
                    urlresolvers.set_urlconf(urlconf)
                    resolver = urlresolvers.RegexURLResolver(u'^/', urlconf)
                resolver_match = resolver.resolve(request.path_info)
                (callback, callback_args, callback_kwargs) = resolver_match
                request.resolver_match = resolver_match
                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__ + u'.__call__')
                raise ValueError((u"The    view    %s.%s    didn't    return    an    HttpResponse    object." % (callback.__module__, view_name)))
            if (hasattr(response, u'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(u'Not    Found:    %s', request.path, extra={u'status_code': 404, u'request': request})
            if settings.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(u'Forbidden    (Permission    denied):    %s', request.path, extra={u'status_code': 403, u'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
