|
77 | 77 | .. automethod:: RequestHandler.async_callback
|
78 | 78 | .. automethod:: RequestHandler.check_xsrf_cookie
|
79 | 79 | .. automethod:: RequestHandler.compute_etag
|
| 80 | + .. automethod:: RequestHandler.create_template_loader |
80 | 81 | .. automethod:: RequestHandler.get_browser_locale
|
81 | 82 | .. automethod:: RequestHandler.get_current_user
|
82 | 83 | .. automethod:: RequestHandler.get_login_url
|
|
97 | 98 | .. autoclass:: Application
|
98 | 99 | :members:
|
99 | 100 |
|
| 101 | + .. attribute:: settings |
| 102 | + |
| 103 | + Additional keyword arguments passed to the constructor are |
| 104 | + saved in the `settings` dictionary, and are often referred to |
| 105 | + in documentation as "application settings". Settings are |
| 106 | + used to customize various aspects of Tornado (although in |
| 107 | + some cases richer customization is possible by overriding |
| 108 | + methods in a subclass of `RequestHandler`). Some |
| 109 | + applications also like to use the `settings` dictionary as a |
| 110 | + way to make application-specific settings available to |
| 111 | + handlers without using global variables. Settings used in |
| 112 | + Tornado are described below. |
| 113 | + |
| 114 | + General settings: |
| 115 | + |
| 116 | + * ``debug``: If ``True`` the application runs in debug mode, |
| 117 | + described in :ref:`debug-mode`. |
| 118 | + * ``gzip``: If ``True``, responses in textual formats will be |
| 119 | + gzipped automatically. |
| 120 | + * ``log_function``: This function will be called at the end |
| 121 | + of every request to log the result (with one argument, the |
| 122 | + `RequestHandler` object). The default implementation |
| 123 | + writes to the `logging` module's root logger. May also be |
| 124 | + customized by overriding `Application.log_request`. |
| 125 | + * ``ui_modules`` and ``ui_methods``: May be set to a mapping |
| 126 | + of `UIModule` or UI methods to be made available to templates. |
| 127 | + May be set to a module, dictionary, or a list of modules |
| 128 | + and/or dicts. See :ref:`ui-modules` for more details. |
| 129 | + |
| 130 | + Authentication and security settings: |
| 131 | + |
| 132 | + * ``cookie_secret``: Used by `RequestHandler.get_secure_cookie` |
| 133 | + and `set_secure_cookie` to sign cookies. |
| 134 | + * ``login_url``: The `authenticated` decorator will redirect |
| 135 | + to this url if the user is not logged in. Can be further |
| 136 | + customized by overriding `RequestHandler.get_login_url` |
| 137 | + * ``xsrf_cookies``: If true, :ref:`xsrf` will be enabled. |
| 138 | + * ``twitter_consumer_key``, ``twitter_consumer_secret``, |
| 139 | + ``friendfeed_consumer_key``, ``friendfeed_consumer_secret``, |
| 140 | + ``google_consumer_key``, ``google_consumer_secret``, |
| 141 | + ``facebook_api_key``, ``facebook_secret``: Used in the |
| 142 | + `tornado.auth` module to authenticate to various APIs. |
| 143 | + |
| 144 | + Template settings: |
| 145 | + |
| 146 | + * ``autoescape``: Controls automatic escaping for templates. |
| 147 | + May be set to ``None`` to disable escaping, or to the *name* |
| 148 | + of a function that all output should be passed through. |
| 149 | + Defaults to ``"xhtml_escape"``. Can be changed on a per-template |
| 150 | + basis with the ``{% autoescape %}`` directive. |
| 151 | + * ``template_path``: Directory containing template files. Can be |
| 152 | + further customized by overriding `RequestHandler.get_template_path` |
| 153 | + * ``template_loader``: Assign to an instance of |
| 154 | + `tornado.template.BaseLoader` to customize template loading. |
| 155 | + If this setting is used the ``template_path`` and ``autoescape`` |
| 156 | + settings are ignored. Can be further customized by overriding |
| 157 | + `RequestHandler.create_template_loader`. |
| 158 | + |
| 159 | + Static file settings: |
| 160 | + |
| 161 | + * ``static_path``: Directory from which static files will be |
| 162 | + served. |
| 163 | + * ``static_url_prefix``: Url prefix for static files, |
| 164 | + defaults to ``"/static/"``. |
| 165 | + * ``static_handler_class``, ``static_handler_args``: May be set to |
| 166 | + use a different handler for static files instead of the default |
| 167 | + `tornado.web.StaticFileHandler`. ``static_handler_args``, if set, |
| 168 | + should be a dictionary of keyword arguments to be passed to the |
| 169 | + handler's ``initialize`` method. |
| 170 | + |
100 | 171 | .. autoclass:: URLSpec
|
101 | 172 |
|
102 | 173 | The ``URLSpec`` class is also available under the name ``tornado.web.url``.
|
|
0 commit comments