deffull_dispatch_request(self): """Dispatches the request and on top of that performs request pre and postprocessing as well as HTTP exception catching and error handling. .. versionadded:: 0.7 """ # 先执行before_first_request注册的中间件函数列表 self.try_trigger_before_first_request_functions() try: # 触发request_started信号 request_started.send(self) # 调用开发者注册的before_request中间件 rv = self.preprocess_request() if rv isNone: # 若返回None,说明中间件没有拦截请求,继续处理 rv = self.dispatch_request() except Exception as e: # 若执行过程出错,尝试使用开发者注册的错误处理器进行错误处理 rv = self.handle_user_exception(e) # 此处的rv实际上就是视图函数返回的响应数据实体,把它再包装成一个callable对象 return self.finalize_request(rv)