move url matching after opening session

This commit is contained in:
David Lord 2019-06-13 12:40:01 -07:00
parent 1ff98a2d21
commit c65863912b
No known key found for this signature in database
GPG key ID: 7A1C87E3F5BC42A8
4 changed files with 26 additions and 17 deletions

View file

@ -347,8 +347,8 @@ class RequestContext(object):
of the request.
"""
try:
url_rule, self.request.view_args = self.url_adapter.match(return_rule=True)
self.request.url_rule = url_rule
result = self.url_adapter.match(return_rule=True)
self.request.url_rule, self.request.view_args = result
except HTTPException as e:
self.request.routing_exception = e
@ -381,9 +381,6 @@ class RequestContext(object):
_request_ctx_stack.push(self)
if self.url_adapter is not None:
self.match_request()
# Open the session at the moment that the request context is available.
# This allows a custom open_session method to use the request context.
# Only open a new session if this is the first time the request was
@ -395,6 +392,9 @@ class RequestContext(object):
if self.session is None:
self.session = session_interface.make_null_session(self.app)
if self.url_adapter is not None:
self.match_request()
def pop(self, exc=_sentinel):
"""Pops the request context and unbinds it by doing that. This will
also trigger the execution of functions registered by the