'Generate a response for the resource at self.path_info. (Core)'

def respond(self, path_info):

    response = cherrypy.serving.response
    try:
        try:
            if (self.app is None):
                raise cherrypy.NotFound()
            self.stage = 'process_headers'
            self.process_headers()
            self.hooks = self.__class__.hooks.copy()
            self.toolmaps = {}
            self.stage = 'get_resource'
            self.get_resource(path_info)
            self.body = _cpreqbody.RequestBody(self.rfile, self.headers, request_params=self.params)
            self.namespaces(self.config)
            self.stage = 'on_start_resource'
            self.hooks.run('on_start_resource')
            self.stage = 'process_query_string'
            self.process_query_string()
            if self.process_request_body:
                if (self.method not in self.methods_with_bodies):
                    self.process_request_body = False
            self.stage = 'before_request_body'
            self.hooks.run('before_request_body')
            if self.process_request_body:
                self.body.process()
            self.stage = 'before_handler'
            self.hooks.run('before_handler')
            if self.handler:
                self.stage = 'handler'
                response.body = self.handler()
            self.stage = 'before_finalize'
            self.hooks.run('before_finalize')
            response.finalize()
        except (cherrypy.HTTPRedirect, cherrypy.HTTPError):
            inst = sys.exc_info()[1]
            inst.set_response()
            self.stage = 'before_finalize    (HTTPError)'
            self.hooks.run('before_finalize')
            response.finalize()
        finally:
            self.stage = 'on_end_resource'
            self.hooks.run('on_end_resource')
    except self.throws:
        raise
    except:
        if self.throw_errors:
            raise
        self.handle_error()
