set TEMPLATE_AUTO_RELOAD default value to None
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by defuz · committed by defuz · parent fe2d75e · Browse files · 4 files·+41 added−15 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+41 added−15 removed
- tests:+27 added−3 removed
- other:+14 added−12 removed
Provenance
- Commit
f88765d- Tree
1b3ed31- Author
defuz <defuz.net@gmail.com>- Committer
defuz <defuz.net@gmail.com>- Parent
fe2d75e
4 files changed+41 added−15 removed
modified:docs/config.rst+6 added-6 removed
180 unmodified lines181 jsonify responses will be pretty printed182 if they are not requested by an183 XMLHttpRequest object (controlled by184 the ``X-Requested-With`` header)185-``TEMPLATES_AUTO_RELOAD`` Flask checks if template was modified each186- time it is requested and reloads it if187- necessary. But disk I/O is costly and it may188- be viable to disable this feature by setting189- this key to ``False``. This option does not190- affect debug mode.185+``TEMPLATES_AUTO_RELOAD`` If this is set to `True` every time a template186+ is requested Flask checks if the template was187+ modified and if yes, it will reload the188+ template. By default the value is ``None``189+ which means that Flask checks template190+ sources only in debug mode.191 ``EXPLAIN_TEMPLATE_LOADING`` If this is enabled then every attempt to192 load a template will write an info193 message to the logger explaining the194 attempts to locate the template. This269 unmodified linesmodified:flask/app.py+5 added-3 removed
295 unmodified lines296 'PREFERRED_URL_SCHEME': 'http',297 'JSON_AS_ASCII': True,298 'JSON_SORT_KEYS': True,299 'JSONIFY_PRETTYPRINT_REGULAR': True,300- 'TEMPLATES_AUTO_RELOAD': True,300+ 'TEMPLATES_AUTO_RELOAD': None,301 })302 303 #: The rule object to use for URL rules created. This is used by304 #: :meth:`add_url_rule`. Defaults to :class:`werkzeug.routing.Rule`.367 unmodified lines672 options = dict(self.jinja_options)673 if 'autoescape' not in options:674 options['autoescape'] = self.select_jinja_autoescape675 if 'auto_reload' not in options:676- options['auto_reload'] = self.debug \677- or self.config['TEMPLATES_AUTO_RELOAD']676+ if self.config['TEMPLATES_AUTO_RELOAD'] is not None:677+ options['auto_reload'] = self.config['TEMPLATES_AUTO_RELOAD']678+ else:679+ options['auto_reload'] = self.debug680 rv = Environment(self, **options)681 rv.globals.update(682 url_for=url_for,683 get_flashed_messages=get_flashed_messages,1226 unmodified linesmodified:tests/test_templating.py+27 added-3 removed
294 unmodified lines295 rv = app.test_client().get('/')296 assert rv.data == b'<h1>Jameson</h1>'297 298 def test_templates_auto_reload():299+ # debug is False, config option is None300 app = flask.Flask(__name__)301+ assert app.debug is False300- assert app.config['TEMPLATES_AUTO_RELOAD']301- assert app.jinja_env.auto_reload302+ assert app.config['TEMPLATES_AUTO_RELOAD'] is None303+ assert app.jinja_env.auto_reload is False304+ # debug is False, config option is False305 app = flask.Flask(__name__)306 app.config['TEMPLATES_AUTO_RELOAD'] = False304- assert not app.jinja_env.auto_reload307+ assert app.debug is False308+ assert app.jinja_env.auto_reload is False309+ # debug is False, config option is True310+ app = flask.Flask(__name__)311+ app.config['TEMPLATES_AUTO_RELOAD'] = True312+ assert app.debug is False313+ assert app.jinja_env.auto_reload is True314+ # debug is True, config option is None315+ app = flask.Flask(__name__)316+ app.config['DEBUG'] = True317+ assert app.config['TEMPLATES_AUTO_RELOAD'] is None318+ assert app.jinja_env.auto_reload is True319+ # debug is True, config option is False320+ app = flask.Flask(__name__)321+ app.config['DEBUG'] = True322+ app.config['TEMPLATES_AUTO_RELOAD'] = False323+ assert app.jinja_env.auto_reload is False324+ # debug is True, config option is True325+ app = flask.Flask(__name__)326+ app.config['DEBUG'] = True327+ app.config['TEMPLATES_AUTO_RELOAD'] = True328+ assert app.jinja_env.auto_reload is True329 330 def test_template_loader_debugging(test_apps):331 from blueprintapp import app332 31 unmodified linesmodified:CHANGES+3 added-3 removed
21 unmodified lines22 from a view function.23 - Added :meth:`flask.Config.from_json`.24 - Added :attr:`flask.Flask.config_class`.25 - Added :meth:`flask.config.Config.get_namespace`.26-- Added ``TEMPLATES_AUTO_RELOAD`` config key. If disabled the27- templates will be reloaded only if the application is running in28- debug mode. For higher performance it’s possible to disable that.26+- Added ``TEMPLATES_AUTO_RELOAD`` config key. Now by default templates will be27+ reloaded every time a template is requested only if the application is28+ running in debug mode.29 - Added a workaround for a limitation in Python 3.3's namespace loader.30 - Added support for explicit root paths when using Python 3.3's namespace31 packages.32 - Added ``flask`` and the ``flask.cli`` module to start the local507 unmodified lines