Split template_cache into two settings, for template and static files.
Rename several options. Update docs.
If you pass ``debug=True`` to the ``Application`` constructor, the app
will be run in debug/development mode. In this mode, several features
-intended for convenience while developing will be enabled:
-
-* The app will watch for changes to its source files and reload itself
- when anything changes. This reduces the need to manually restart the
- server during development. However, certain failures (such as syntax
- errors at import time) can still take the server down in a way that
- debug mode cannot currently recover from.
-* Templates will not be cached, nor will static file hashes (used by the
- ``static_url`` function)
-* When an exception in a ``RequestHandler`` is not caught, an error
- page including a stack trace will be generated.
-
-Debug mode is not compatible with ``HTTPServer``'s multi-process mode.
+intended for convenience while developing will be enabled (each of which
+is also available as an individual flag; if both are specified the
+individual flag takes precedence):
+
+* ``autoreload=True``: The app will watch for changes to its source
+ files and reload itself when anything changes. This reduces the need
+ to manually restart the server during development. However, certain
+ failures (such as syntax errors at import time) can still take the
+ server down in a way that debug mode cannot currently recover from.
+* ``compiled_template_cache=False``: Templates will not be cached.
+* ``static_hash_cache=False``: Static file hashes (used by the
+ ``static_url`` function) will not be cached
+* ``serve_traceback=True``: When an exception in a ``RequestHandler``
+ is not caught, an error page including a stack trace will be
+ generated.
+
+Autoreload mode is not compatible with ``HTTPServer``'s multi-process mode.
You must not give ``HTTPServer.start`` an argument other than 1 (or
-call `tornado.process.fork_processes`) if you are using debug mode.
+call `tornado.process.fork_processes`) if you are using autoreload mode.
The automatic reloading feature of debug mode is available as a
standalone module in ``tornado.autoreload``. The two can be used in
combination to provide extra robustness against syntax errors: set
-``debug=True`` within the app to detect changes while it is running,
+``autoreload=True`` within the app to detect changes while it is running,
and start it with ``python -m tornado.autoreload myserver.py`` to catch
any syntax errors or other errors at startup.
"""xAutomatically restart the server when a source file is modified.
-Most applications should not access this module directly. Instead, pass the
-keyword argument ``debug=True`` to the `tornado.web.Application` constructor.
-This will enable autoreload mode as well as checking for changes to templates
-and static resources. Note that restarting is a destructive operation
-and any requests in progress will be aborted when the process restarts.
-(If you want to disable autoreload while keeping debug on pass in also the
-keyword argument ``autoreload=False``).
+Most applications should not access this module directly. Instead,
+pass the keyword argument ``autoreload=True`` to the
+`tornado.web.Application` constructor (or ``debug=True``, which
+enables this setting and several others). This will enable autoreload
+mode as well as checking for changes to templates and static
+resources. Note that restarting is a destructive operation and any
+requests in progress will be aborted when the process restarts. (If
+you want to disable autoreload while using other debug-mode features,
+pass both ``debug=True`` and ``autoreload=False``).
This module can also be used as a command-line wrapper around scripts
such as unit test runners. See the `main` method for details.
because it re-executes Python using ``sys.executable`` and ``sys.argv``.
Additionally, modifying these variables will cause reloading to behave
incorrectly.
+
"""
from __future__ import absolute_import, division, print_function, with_statement
else:
self.finish(self.get_error_html(status_code, **kwargs))
return
- if self.settings.get("debug_traceback") and "exc_info" in kwargs:
+ if self.settings.get("serve_traceback") and "exc_info" in kwargs:
# in debug mode, try to send a traceback
self.set_header('Content-Type', 'text/plain')
for line in traceback.format_exception(*kwargs["exc_info"]):
if self.settings.get('debug'):
self.settings.setdefault('autoreload', True)
- self.settings.setdefault('template_cache', False)
- self.settings.setdefault('debug_traceback', True)
+ self.settings.setdefault('compiled_template_cache', False)
+ self.settings.setdefault('static_hash_cache', False)
+ self.settings.setdefault('serve_traceback', True)
# Automatically reload modified modules
if self.settings.get('autoreload') and not wsgi:
# If template cache is disabled (usually in the debug mode),
# re-compile templates and reload static files on every
# request so you don't need to restart to see changes
- if not self.settings.get("template_cache"):
+ if not self.settings.get("compiled_template_cache", True):
with RequestHandler._template_loader_lock:
for loader in RequestHandler._template_loaders.values():
loader.reset()
+ if not self.settings.get('static_hash_cache', True):
StaticFileHandler.reset()
handler._execute(transforms, *args, **kwargs)