Skip to content
Myr

add TEMPLATES_AUTO_RELOAD option to config

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

authored by defuz · committed by defuz · parent 5d20501 · Browse files · 4 files+28 added−0 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+28 added−0 removed

  • other:+28 added−0 removed

4 files+28 added−0 removed

modified:docs/config.rst+9 added
172 unmodified lines
173 jsonify responses will be pretty printed174 if they are not requested by an175 XMLHttpRequest object (controlled by176 the ``X-Requested-With`` header)177``TEMPLATES_AUTO_RELOAD`` Flask checks if template was modified each178 time it is requested and reloads it if179 necessary. But disk I/O is costly and it may180 be viable to disable this feature by setting181 this key to ``False``. This option does not182 affect debug mode.183================================= =========================================184185.. admonition:: More on ``SERVER_NAME``186
40 unmodified lines
227228.. versionadded:: 1.0229 ``SESSION_REFRESH_EACH_REQUEST``230231.. versionadded:: 1.0232 ``TEMPLATES_AUTO_RELOAD``233234Configuring from Files235----------------------236237Configuration becomes more useful if you can store it in a separate file,
213 unmodified lines
modified:flask/testsuite/templating.py+8 added
293 unmodified lines
294295 rv = app.test_client().get('/')296 self.assert_equal(rv.data, b'<h1>Jameson</h1>')297298 def test_templates_auto_reload(self):299 app = flask.Flask(__name__)300 self.assert_true(app.config['TEMPLATES_AUTO_RELOAD'])301 self.assert_true(app.jinja_env.auto_reload)302 app = flask.Flask(__name__)303 app.config['TEMPLATES_AUTO_RELOAD'] = False304 self.assert_false(app.jinja_env.auto_reload)305306307def suite():308 suite = unittest.TestSuite()309 suite.addTest(unittest.makeSuite(TemplatingTestCase))310 return suite
modified:flask/app.py+7 added
292 unmodified lines
293 'PREFERRED_URL_SCHEME': 'http',294 'JSON_AS_ASCII': True,295 'JSON_SORT_KEYS': True,296 'JSONIFY_PRETTYPRINT_REGULAR': True,297 'TEMPLATES_AUTO_RELOAD': True,298 })299300 #: The rule object to use for URL rules created. This is used by301 #: :meth:`add_url_rule`. Defaults to :class:`werkzeug.routing.Rule`.
342 unmodified lines
644 the Jinja2 globals and filters after initialization. Override645 this function to customize the behavior.646647 .. versionadded:: 0.5648 .. versionchanged:: 1.0649 ``Environment.auto_reload`` set in accordance with650 ``TEMPLATES_AUTO_RELOAD`` configuration option.651 """652 options = dict(self.jinja_options)653 if 'autoescape' not in options:654 options['autoescape'] = self.select_jinja_autoescape655 if 'auto_reload' not in options:656 options['auto_reload'] = self.debug \657 or self.config['TEMPLATES_AUTO_RELOAD']658 rv = Environment(self, **options)659 rv.globals.update(660 url_for=url_for,661 get_flashed_messages=get_flashed_messages,
1186 unmodified lines
modified:CHANGES+4 added
13 unmodified lines
14 `False` it will only be modified if the session actually modifies.15 Non permanent sessions are not affected by this and will always16 expire if the browser window closes.1718- Added ``TEMPLATES_AUTO_RELOAD`` config key. If disabled the 19 templates will be reloaded only if the application is running in 20 debug mode. For higher performance it’s possible to disable that.2122Version 0.10.223--------------2425(bugfix release, release date to be announced)
466 unmodified lines