Ensure session_interface.open_session is called after URL matching (#3776)

This commit is contained in:
Matthew Preble 2020-10-16 20:57:56 -05:00 committed by David Lord
parent 15f0fc2d24
commit 01621485fd
No known key found for this signature in database
GPG key ID: 7A1C87E3F5BC42A8
3 changed files with 28 additions and 3 deletions

View file

@ -361,6 +361,9 @@ class RequestContext:
_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
@ -372,9 +375,6 @@ class RequestContext:
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