Skip to content
Myr

Merge pull request #876 from defuz/templates-auto-reload

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

Add TEMPLATES_AUTO_RELOAD config key

authored by Kenneth Reitz · committed by Kenneth Reitz · parents 4c0253f, 3e48500 · 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
303 unmodified lines
304 'PREFERRED_URL_SCHEME': 'http',305 'JSON_AS_ASCII': True,306 'JSON_SORT_KEYS': True,307 'JSONIFY_PRETTYPRINT_REGULAR': True,308 'TEMPLATES_AUTO_RELOAD': True,309 })310311 #: The rule object to use for URL rules created. This is used by312 #: :meth:`add_url_rule`. Defaults to :class:`werkzeug.routing.Rule`.
342 unmodified lines
655 the Jinja2 globals and filters after initialization. Override656 this function to customize the behavior.657658 .. versionadded:: 0.5659 .. versionchanged:: 1.0660 ``Environment.auto_reload`` set in accordance with661 ``TEMPLATES_AUTO_RELOAD`` configuration option.662 """663 options = dict(self.jinja_options)664 if 'autoescape' not in options:665 options['autoescape'] = self.select_jinja_autoescape666 if 'auto_reload' not in options:667 options['auto_reload'] = self.debug \668 or self.config['TEMPLATES_AUTO_RELOAD']669 rv = Environment(self, **options)670 rv.globals.update(671 url_for=url_for,672 get_flashed_messages=get_flashed_messages,
1194 unmodified lines
modified:CHANGES+4 added
19 unmodified lines
20- Added :meth:`flask.Config.from_json`.21- Added :attr:`flask.Flask.config_class`.22- Added :meth:`flask.config.Config.get_namespace`.2324- Added ``TEMPLATES_AUTO_RELOAD`` config key. If disabled the 25 templates will be reloaded only if the application is running in 26 debug mode. For higher performance it’s possible to disable that.2728Version 0.10.229--------------3031(bugfix release, release date to be announced)
477 unmodified lines