我正在研究django中间件代码库 . 我看了下面的图
enter image description here

所以,图表非常清楚 .

但我有一些问题

  • 当process_request()中间件出现异常时会发生什么?怎么处理?是否会调用response_middleware?例如 . 如果 AuthenticationMiddlewareprocess_view() 出现异常,那么 MessageMiddlewareprocess_response() 会被调用吗?

  • 在process_response()中间件返回响应时会发生什么?例如 . 如果 process_view()AuthenticationMiddleware 返回响应,那么 MessageMiddlewareprocess_response() 会被调用吗?或者它将从 AuthenticationMiddleware 返回(即,它将调用 AuthenticationMiddlewareprocess_response() ,但不会调用 process_response()process_response()

我已经在1.10中调试了django的行为,其中使用了新的中间件类,但我不熟悉旧的 MIDDLEWARE_CLASSES 设置?

对于django 1.10: - 1)如果 process_request() for AuthenticationMiddleware 返回响应,则将调用 process_template_response()process_response() ,如下图所示的所有中间件 .

2)如果 AuthenticationMiddlewareAuthenticationMiddleware 引发异常,那么行为也将是相同的 .

纠正我,如果我错了 .

提前致谢 .