Skip to content
Myr

Merge branch 'ThiefMaster-override-jinja-env'

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

authored by Markus Unterwaditzer · committed by Markus Unterwaditzer · parents 5ebf1e8, 2446ca6 · Browse files · 4 files+18 added−3 removed
This commit

State

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

Diff stats

4 files+18 added−3 removed

  • tests:+10 added−0 removed
  • other:+8 added−3 removed

4 files+18 added−3 removed

modified:flask/app.py+6 added-1 removed
155 unmodified lines
156 #: The class that is used for response objects. See157 #: :class:`~flask.Response` for more information.158 response_class = Response159160 #: The class that is used for the Jinja environment.161 #:162 #: .. versionadded:: 1.0163 jinja_env_class = Environment164165 #: The class that is used for the :data:`~flask.g` instance.166 #:167 #: Example use cases for a custom class:168 #:
515 unmodified lines
684 if self.config['TEMPLATES_AUTO_RELOAD'] is not None:685 options['auto_reload'] = self.config['TEMPLATES_AUTO_RELOAD']686 else:687 options['auto_reload'] = self.debug683 rv = Environment(self, **options)688 rv = self.jinja_env_class(self, **options)689 rv.globals.update(690 url_for=url_for,691 get_flashed_messages=get_flashed_messages,692 config=self.config,
1289 unmodified lines
modified:flask/blueprints.py+1 added-1 removed
406 unmodified lines
407 function, akin to the :meth:`~flask.Flask.register_error_handler`408 application-wide function of the :class:`~flask.Flask` object but409 for error handlers limited to this blueprint.410411 .. versionadded:: 0.11411 .. versionadded:: 1.0412 """413 self.record_once(lambda s: s.app._register_error_handler(414 self.name, code_or_exception, f))
modified:flask/wrappers.py+1 added-1 removed
111 unmodified lines
112 """Indicates if this request is JSON or not. By default a request113 is considered to include JSON data if the mimetype is114 :mimetype:`application/json` or :mimetype:`application/*+json`.115116 .. versionadded:: 0.11116 .. versionadded:: 1.0117 """118 mt = self.mimetype119 if mt == 'application/json':120 return True
83 unmodified lines
modified:tests/test_templating.py+10 added
359 unmodified lines
360 app.logger.handlers[:] = old_handlers361 app.config['EXPLAIN_TEMPLATE_LOADING'] = old_load_setting362363 assert len(called) == 1364365def test_custom_jinja_env():366 class CustomEnvironment(flask.templating.Environment):367 pass368369 class CustomFlask(flask.Flask):370 jinja_env_class = CustomEnvironment371372 app = CustomFlask(__name__)373 assert isinstance(app.jinja_env, CustomEnvironment)