Custom request-scoped global proxy with Flask 2.3 #5261
-
I have an application using Flask from flask import _request_ctx_stack
from werkzeug.local import LocalProxy
current_org = LocalProxy(
lambda: getattr(_request_ctx_stack.top, "current_org", None)
)
current_identity = LocalProxy(
lambda: getattr(_request_ctx_stack.top, "current_identity", None)
)
current_schema = LocalProxy(
lambda: getattr(_request_ctx_stack.top, "current_schema", None)
)
# This is how values are assigned in a single place
_request_ctx_stack.top.current_org = value
... The documentation says we should be using the Is it still possible to have custom global proxies bound to the current request context in Flask 2.3? |
Beta Was this translation helpful? Give feedback.
Answered by
ThiefMaster
Sep 21, 2023
Replies: 1 comment 1 reply
-
Why not simply change your lookup callback to get it from current_org = LocalProxy(lambda: g.get('current_org')) |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
mbarakaja
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why not simply change your lookup callback to get it from
g
instead of the request ctx stack?