converters have access to session

This commit is contained in:
David Lord 2021-05-14 08:11:09 -07:00
parent 8648750997
commit a7b02b3a07
No known key found for this signature in database
GPG key ID: 7A1C87E3F5BC42A8
4 changed files with 28 additions and 16 deletions

View file

@ -395,9 +395,6 @@ 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
@ -409,6 +406,11 @@ class RequestContext:
if self.session is None:
self.session = session_interface.make_null_session(self.app)
# Match the request URL after loading the session, so that the
# session is available in custom URL converters.
if self.url_adapter is not None:
self.match_request()
def pop(self, exc: t.Optional[BaseException] = _sentinel) -> None: # type: ignore
"""Pops the request context and unbinds it by doing that. This will
also trigger the execution of functions registered by the