forked from orbit-oss/flask
deprecate RequestContext.g
This commit is contained in:
parent
04c6a85518
commit
c8ddb948f6
2 changed files with 22 additions and 2 deletions
|
|
@ -332,11 +332,29 @@ class RequestContext:
|
|||
self._after_request_functions: t.List[AfterRequestCallable] = []
|
||||
|
||||
@property
|
||||
def g(self) -> AppContext:
|
||||
def g(self) -> _AppCtxGlobals:
|
||||
import warnings
|
||||
|
||||
warnings.warn(
|
||||
"Accessing 'g' on the request context is deprecated and"
|
||||
" will be removed in Flask 2.2. Access `g` directly or from"
|
||||
"the application context instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return _app_ctx_stack.top.g
|
||||
|
||||
@g.setter
|
||||
def g(self, value: AppContext) -> None:
|
||||
def g(self, value: _AppCtxGlobals) -> None:
|
||||
import warnings
|
||||
|
||||
warnings.warn(
|
||||
"Setting 'g' on the request context is deprecated and"
|
||||
" will be removed in Flask 2.2. Set it on the application"
|
||||
" context instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
_app_ctx_stack.top.g = value
|
||||
|
||||
def copy(self) -> "RequestContext":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue