]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Polish for extra debug-mode settings.
authorBen Darnell <ben@bendarnell.com>
Sun, 6 Oct 2013 00:38:39 +0000 (20:38 -0400)
committerBen Darnell <ben@bendarnell.com>
Sun, 6 Oct 2013 00:38:39 +0000 (20:38 -0400)
Split template_cache into two settings, for template and static files.
Rename several options.  Update docs.

docs/overview.rst
tornado/autoreload.py
tornado/web.py

index 6bd6ca0d28e24dc1e62eff57f3dbde3f8d0683bb..a85a970ebea9d20eb82a3a0abd59d870c924f14d 100644 (file)
@@ -972,26 +972,30 @@ Debug mode and automatic reloading
 
 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.
 
index 7fc1fc359ae44b02e5df9178d378b6ebfdc041cf..79cccb498ed84b77dd6dfb98ce39318e0eaf96e3 100644 (file)
 
 """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.
@@ -40,6 +42,7 @@ Reloading loses any Python interpreter command-line arguments (e.g. ``-u``)
 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
index 7692de7534db20caa191c4a35ae7d3f3d9156dff..b820d9645981bb9aa330ce7d27f1d763a53b3f41 100644 (file)
@@ -889,7 +889,7 @@ class RequestHandler(object):
             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"]):
@@ -1500,8 +1500,9 @@ class Application(object):
 
         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:
@@ -1665,10 +1666,11 @@ class Application(object):
         # 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)