forked from orbit-oss/flask
wait until app ctx is ready before matching url
`RequestContext.match_request` is moved from `__init__` to `push`. This causes matching to happen later, when the app context is available. This enables URL converters that use things such as the database.
This commit is contained in:
parent
29111a3259
commit
1ff98a2d21
4 changed files with 41 additions and 24 deletions
|
|
@ -314,9 +314,6 @@ class RequestContext(object):
|
|||
# functions.
|
||||
self._after_request_functions = []
|
||||
|
||||
if self.url_adapter is not None:
|
||||
self.match_request()
|
||||
|
||||
@property
|
||||
def g(self):
|
||||
return _app_ctx_stack.top.g
|
||||
|
|
@ -384,6 +381,9 @@ 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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue