Skip to content
Myr

Added proxies to template context

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

authored by Armin Ronacher · committed by Armin Ronacher · parent 1949c4a · Browse files · 2 files+12 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+12 added−2 removed

  • other:+12 added−2 removed

2 files+12 added−2 removed

modified:flask/app.py+8 added-2 removed
27 unmodified lines
28from . import json29from .wrappers import Request, Response30from .config import ConfigAttribute, Config31from .ctx import RequestContext, AppContext, _AppCtxGlobals32from .globals import _request_ctx_stack, request32from .globals import _request_ctx_stack, request, session, g33from .sessions import SecureCookieSessionInterface34from .module import blueprint_is_module35from .templating import DispatchingJinjaLoader, Environment, \36 _default_template_ctx_processor
625 unmodified lines
662 rv = Environment(self, **options)663 rv.globals.update(664 url_for=url_for,665 get_flashed_messages=get_flashed_messages,666 config=self.config666 config=self.config,667 # request, session and g are normally added with the668 # context processor for efficiency reasons but for imported669 # templates we also want the proxies in there.670 request=request,671 session=session,672 g=g673 )674 rv.filters['tojson'] = json.htmlsafe_dumps675 return rv676
1104 unmodified lines
modified:CHANGES+4 added
37 unmodified lines
38 context.39- ``flask.Flask.request_globals_class`` got renamed to40 ``flask.Flask.app_ctx_globals_class`` which is a better name to what it41 does since 0.10.42- `request`, `session` and `g` are now also added as proxies to the template43 context which makes them available in imported templates. One has to be44 very careful with those though because usage outside of macros might45 cause caching.4647Version 0.948-----------49
365 unmodified lines