Skip to content
Myr

Merge pull request #4342 from pallets/deprecate-req-ctx-g

Before adoption: this commit came in with the history the project adopted, so no landing records it.

deprecate `RequestContext.g`

authored by David Lord · committed by GitHub · parents 04c6a85, c8ddb94 · Browse files · 2 files+22 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+22 added−2 removed

  • other:+22 added−2 removed

2 files+22 added−2 removed

modified:src/flask/ctx.py+20 added-2 removed
330 unmodified lines
331 # functions.332 self._after_request_functions: t.List[AfterRequestCallable] = []333334 @property335 def g(self) -> AppContext:335 def g(self) -> _AppCtxGlobals:336 import warnings337338 warnings.warn(339 "Accessing 'g' on the request context is deprecated and"340 " will be removed in Flask 2.2. Access `g` directly or from"341 "the application context instead.",342 DeprecationWarning,343 stacklevel=2,344 )345 return _app_ctx_stack.top.g346347 @g.setter339 def g(self, value: AppContext) -> None:348 def g(self, value: _AppCtxGlobals) -> None:349 import warnings350351 warnings.warn(352 "Setting 'g' on the request context is deprecated and"353 " will be removed in Flask 2.2. Set it on the application"354 " context instead.",355 DeprecationWarning,356 stacklevel=2,357 )358 _app_ctx_stack.top.g = value359360 def copy(self) -> "RequestContext":361 """Creates a copy of this request context with the same request object.
137 unmodified lines
modified:CHANGES.rst+2 added
27 unmodified lines
28 - ``cache_timeout`` is renamed to ``max_age``.29 - ``add_etags`` is renamed to ``etag``.30 - ``filename`` is renamed to ``path``.3132- The ``RequestContext.g`` property is deprecated. Use ``g`` directly33 or ``AppContext.g`` instead. :issue:`3898`34- ``copy_current_request_context`` can decorate async functions.35 :pr:`4303`3637
1196 unmodified lines