docs: ``True``, ``False`` and ``None``
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by defuz · committed by defuz · parent 6dbb015 · Browse files · 19 files·+99 added−99 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
19 files+99 added−99 removed
- other:+99 added−99 removed
Provenance
- Commit
8284217- Tree
0868e5b- Author
defuz <defuz.net@gmail.com>- Committer
defuz <defuz.net@gmail.com>- Parent
6dbb015
19 files changed+99 added−99 removed
modified:docs/patterns/appdispatch.rst+1 added-1 removed
174 unmodified lines175 app = self.default_app176 return app(environ, start_response)177 178 The big difference between this and the subdomain one is that this one179-falls back to another application if the creator function returns `None`::179+falls back to another application if the creator function returns ``None``::180 181 from myapplication import create_app, default_app, get_user_for_prefix182 183 def make_app(prefix):5 unmodified linesmodified:docs/patterns/caching.rst+1 added-1 removed
48 unmodified lines49 50 To get an item from the cache call51 :meth:`~werkzeug.contrib.cache.BaseCache.get` with a string as key name.52 If something is in the cache, it is returned. Otherwise that function53-will return `None`::53+will return ``None``::54 55 rv = cache.get('my-item')56 57 To add items to the cache, use the :meth:`~werkzeug.contrib.cache.BaseCache.set`12 unmodified linesmodified:docs/patterns/distribute.rst+1 added-1 removed
107 unmodified lines108 recursive-include yourapplication/static *109 110 Don't forget that even if you enlist them in your `MANIFEST.in` file, they111 won't be installed for you unless you set the `include_package_data`112-parameter of the `setup` function to `True`!112+parameter of the `setup` function to ``True``!113 114 115 Declaring Dependencies116 ----------------------50 unmodified linesmodified:docs/patterns/mongokit.rst+1 added-1 removed
74 unmodified lines75 76 This example shows you how to define your schema (named structure), a77 validator for the maximum character length and uses a special MongoKit feature78 called `use_dot_notation`. Per default MongoKit behaves like a python79-dictionary but with `use_dot_notation` set to `True` you can use your79+dictionary but with `use_dot_notation` set to ``True`` you can use your80 documents like you use models in nearly any other ORM by using dots to81 separate between attributes.82 83 You can insert entries into the database like this:58 unmodified linesmodified:docs/patterns/viewdecorators.rst+9 added-9 removed
21 unmodified lines22 often forgotten, but you don't have to do that by hand, there is a23 function for that that is used like a decorator (:func:`functools.wraps`).24 25 This example assumes that the login page is called ``'login'`` and that26-the current user is stored as `g.user` and `None` if there is no-one26+the current user is stored as `g.user` and ``None`` if there is no-one27 logged in::28 29 from functools import wraps30 from flask import g, request, redirect, url_for88 unmodified lines119 As you can see, if no template name is provided it will use the endpoint120 of the URL map with dots converted to slashes + ``'.html'``. Otherwise121 the provided template name is used. When the decorated function returns,122 the dictionary returned is passed to the template rendering function. If123-`None` is returned, an empty dictionary is assumed, if something else than123+``None`` is returned, an empty dictionary is assumed, if something else than124 a dictionary is returned we return it from the function unchanged. That125 way you can still use the redirect function or return simple strings.126 127 Here is the code for that decorator::22 unmodified lines150 Endpoint Decorator151 ------------------152 153 When you want to use the werkzeug routing system for more flexibility you154-need to map the endpoint as defined in the :class:`~werkzeug.routing.Rule` 155-to a view function. This is possible with this decorator. For example:: 154+need to map the endpoint as defined in the :class:`~werkzeug.routing.Rule`155+to a view function. This is possible with this decorator. For example::156 157 from flask import Flask158 from werkzeug.routing import Rule159 160- app = Flask(__name__) 161- app.url_map.add(Rule('/', endpoint='index')) 160+ app = Flask(__name__)161+ app.url_map.add(Rule('/', endpoint='index'))162 163- @app.endpoint('index') 164- def my_index(): 165- return "Hello world" 163+ @app.endpoint('index')164+ def my_index():165+ return "Hello world"modified:docs/patterns/wtforms.rst+1 added-1 removed
62 unmodified lines63 1. create the form from the request :attr:`~flask.request.form` value if64 the data is submitted via the HTTP `POST` method and65 :attr:`~flask.request.args` if the data is submitted as `GET`.66 2. to validate the data, call the :func:`~wtforms.form.Form.validate`67- method which will return `True` if the data validates, `False`67+ method which will return ``True`` if the data validates, ``False``68 otherwise.69 3. to access individual values from the form, access `form.<NAME>.data`.70 71 Forms in Templates55 unmodified linesmodified:docs/tutorial/dbcon.rst+1 added-1 removed
51 unmodified lines52 every time the app context tears down. So what does this mean?53 Essentially the app context is created before the request comes in and is54 destroyed (torn down) whenever the request finishes. A teardown can55 happen because of two reasons: either everything went well (the error56-parameter will be `None`) or an exception happened in which case the error56+parameter will be ``None``) or an exception happened in which case the error57 is passed to the teardown function.58 59 Curious about what these contexts mean? Have a look at the60 :ref:`app-context` documentation to learn more.18 unmodified linesmodified:docs/tutorial/views.rst+2 added-2 removed
44 unmodified lines45 flash('New entry was successfully posted')46 return redirect(url_for('show_entries'))47 48 Note that we check that the user is logged in here (the `logged_in` key is49-present in the session and `True`).49+present in the session and ``True``).50 51 .. admonition:: Security Note52 53 Be sure to use question marks when building SQL statements, as done in the6 unmodified lines60 61 These functions are used to sign the user in and out. Login checks the62 username and password against the ones from the configuration and sets the63 `logged_in` key in the session. If the user logged in successfully, that64-key is set to `True`, and the user is redirected back to the `show_entries`64+key is set to ``True``, and the user is redirected back to the `show_entries`65 page. In addition, a message is flashed that informs the user that he or66 she was logged in successfully. If an error occurred, the template is67 notified about that, and the user is asked again::68 30 unmodified linesmodified:docs/api.rst+9 added-9 removed
113 unmodified lines114 ============= ======================================================115 116 .. attribute:: is_xhr117 118- `True` if the request was triggered via a JavaScript118+ ``True`` if the request was triggered via a JavaScript119 `XMLHttpRequest`. This only works with libraries that support the120 ``X-Requested-With`` header and set it to `XMLHttpRequest`.121 Libraries that do that are prototype, jQuery and Mochikit and122 probably some more.54 unmodified lines177 The following attributes are interesting:178 179 .. attribute:: new180 181- `True` if the session is new, `False` otherwise.181+ ``True`` if the session is new, ``False`` otherwise.182 183 .. attribute:: modified184 185- `True` if the session object detected a modification. Be advised185+ ``True`` if the session object detected a modification. Be advised186 that modifications on mutable structures are not picked up187 automatically, in that situation you have to explicitly set the188- attribute to `True` yourself. Here an example::188+ attribute to ``True`` yourself. Here an example::189 190 # this change is not picked up because a mutable object (here191 # a list) is changed.192 session['objects'].append(42)1 unmodified line194 session.modified = True195 196 .. attribute:: permanent197 198- If set to `True` the session lives for198+ If set to ``True`` the session lives for199 :attr:`~flask.Flask.permanent_session_lifetime` seconds. The200- default is 31 days. If set to `False` (which is the default) the200+ default is 31 days. If set to ``False`` (which is the default) the201 session will be deleted when the user closes the browser.202 203 204 Session Interface73 unmodified lines278 is especially useful when combined with the :ref:`faking-resources`279 pattern for testing.280 281 Additionally as of 0.10 you can use the :meth:`get` method to282- get an attribute or `None` (or the second argument) if it's not set.282+ get an attribute or ``None`` (or the second argument) if it's not set.283 These two usages are now equivalent::284 285 user = getattr(flask.g, 'user', None)286 user = flask.g.get('user', None)228 unmodified lines515 .. versionadded:: 0.6516 517 .. data:: signals_available518 519- `True` if the signaling system is available. This is the case519+ ``True`` if the signaling system is available. This is the case520 when `blinker`_ is installed.521 522 .. data:: template_rendered523 257 unmodified lines781 782 A special decorator that informs a click callback to be passed the783 script info object as first argument. This is normally not useful784 unless you implement very special commands like the run command which785- does not want the application to be loaded yet. 785+ does not want the application to be loaded yet.786 787 .. autodata:: run_command788 789 .. autodata:: shell_commandmodified:docs/config.rst+5 added-5 removed
54 unmodified lines55 ``DEBUG`` enable/disable debug mode56 ``TESTING`` enable/disable testing mode57 ``PROPAGATE_EXCEPTIONS`` explicitly enable or disable the58 propagation of exceptions. If not set or59- explicitly set to `None` this is59+ explicitly set to ``None`` this is60 implicitly true if either `TESTING` or61 `DEBUG` is true.62 ``PRESERVE_CONTEXT_ON_EXCEPTION`` By default if the application is in63 debug mode the request context is not15 unmodified lines79 for all of ``APPLICATION_ROOT`` or if80 that is not set for ``'/'``.81 ``SESSION_COOKIE_HTTPONLY`` controls if the cookie should be set82 with the httponly flag. Defaults to83- `True`.83+ ``True``.84 ``SESSION_COOKIE_SECURE`` controls if the cookie should be set85 with the secure flag. Defaults to86- `False`.86+ ``False``.87 ``PERMANENT_SESSION_LIFETIME`` the lifetime of a permanent session as88 :class:`datetime.timedelta` object.89 Starting with Flask 0.8 this can also be90 an integer representing seconds.91 ``SESSION_REFRESH_EACH_REQUEST`` this flag controls how permanent92- sessions are refreshed. If set to `True`92+ sessions are refreshed. If set to ``True``93 (which is the default) then the cookie94 is refreshed each request which95 automatically bumps the lifetime. If96- set to `False` a `set-cookie` header is96+ set to ``False`` a `set-cookie` header is97 only sent if the session is modified.98 Non permanent sessions are not affected99 by this.100 ``USE_X_SENDFILE`` enable/disable x-sendfile362 unmodified linesmodified:docs/styleguide.rst+1 added-1 removed
106 unmodified lines107 Comparisons:108 - against arbitrary types: ``==`` and ``!=``109 - against singletons with ``is`` and ``is not`` (eg: ``foo is not110 None``)111- - never compare something with `True` or `False` (for example never111+ - never compare something with ``True`` or ``False`` (for example never112 do ``foo == False``, do ``not foo`` instead)113 114 Negated containment checks:115 use ``foo not in bar`` instead of ``not foo in bar``85 unmodified linesmodified:flask/app.py+26 added-26 removed
133 unmodified lines134 :param instance_path: An alternative instance path for the application.135 By default the folder ``'instance'`` next to the136 package or module is assumed to be the instance137 path.138- :param instance_relative_config: if set to `True` relative filenames138+ :param instance_relative_config: if set to ``True`` relative filenames139 for loading the config are assumed to140 be relative to the instance path instead141 of the application root.142 :param root_path: Flask by default will automatically calculate the path49 unmodified lines192 #:193 #: .. versionadded:: 1.0194 config_class = Config195 196- #: The debug flag. Set this to `True` to enable debugging of the196+ #: The debug flag. Set this to ``True`` to enable debugging of the197 #: application. In debug mode the debugger will kick in when an unhandled198 #: exception occurs and the integrated server will automatically reload199 #: the application if changes in the code are detected.200 #:201 #: This attribute can also be configured from the config with the `DEBUG`202- #: configuration key. Defaults to `False`.202+ #: configuration key. Defaults to ``False``.203 debug = ConfigAttribute('DEBUG')204 205- #: The testing flag. Set this to `True` to enable the test mode of205+ #: The testing flag. Set this to ``True`` to enable the test mode of206 #: Flask extensions (and in the future probably also Flask itself).207 #: For example this might activate unittest helpers that have an208 #: additional runtime cost which should not be enabled by default.209 #:210 #: If this is enabled and PROPAGATE_EXCEPTIONS is not changed from the211 #: default it's implicitly enabled.212 #:213 #: This attribute can also be configured from the config with the214- #: `TESTING` configuration key. Defaults to `False`.214+ #: `TESTING` configuration key. Defaults to ``False``.215 testing = ConfigAttribute('TESTING')216 217 #: If a secret key is set, cryptographic components can use this to218 #: sign cookies and other things. Set this to a complex random value219 #: when you want to use the secure cookie for instance.220 #:221 #: This attribute can also be configured from the config with the222- #: `SECRET_KEY` configuration key. Defaults to `None`.222+ #: `SECRET_KEY` configuration key. Defaults to ``None``.223 secret_key = ConfigAttribute('SECRET_KEY')224 225 #: The secure cookie uses this for the name of the session cookie.226 #:17 unmodified lines244 #:245 #: .. versionadded:: 0.2246 #:247 #: This attribute can also be configured from the config with the248- #: `USE_X_SENDFILE` configuration key. Defaults to `False`.248+ #: `USE_X_SENDFILE` configuration key. Defaults to ``False``.249 use_x_sendfile = ConfigAttribute('USE_X_SENDFILE')250 251 #: The name of the logger to use. By default the logger name is the252 #: package name passed to the constructor.110 unmodified lines363 # support for the now deprecated `error_handlers` attribute. The364 # :attr:`error_handler_spec` shall be used now.365 self._error_handlers = {}366 367- #: A dictionary of all registered error handlers. The key is `None`367+ #: A dictionary of all registered error handlers. The key is ``None``368 #: for error handlers active on the application, otherwise the key is369 #: the name of the blueprint. Each key points to another dictionary370 #: where the key is the status code of the http exception. The371- #: special key `None` points to a list of tuples where the first item371+ #: special key ``None`` points to a list of tuples where the first item372 #: is the class for the instance check and the second the error handler373 #: function.374 #:375 #: To register a error handler, use the :meth:`errorhandler`2 unmodified lines378 379 #: A list of functions that are called when :meth:`url_for` raises a380 #: :exc:`~werkzeug.routing.BuildError`. Each function registered here381 #: is called with `error`, `endpoint` and `values`. If a function382- #: returns `None` or raises a `BuildError` the next function is382+ #: returns ``None`` or raises a `BuildError` the next function is383 #: tried.384 #:385 #: .. versionadded:: 0.9386 self.url_build_error_handlers = []387 388 #: A dictionary with lists of functions that should be called at the389 #: beginning of the request. The key of the dictionary is the name of390- #: the blueprint this function is active for, `None` for all requests.390+ #: the blueprint this function is active for, ``None`` for all requests.391 #: This can for example be used to open database connections or392 #: getting hold of the currently logged in user. To register a393 #: function here, use the :meth:`before_request` decorator.394 self.before_request_funcs = {}6 unmodified lines401 self.before_first_request_funcs = []402 403 #: A dictionary with lists of functions that should be called after404 #: each request. The key of the dictionary is the name of the blueprint405- #: this function is active for, `None` for all requests. This can for405+ #: this function is active for, ``None`` for all requests. This can for406 #: example be used to open database connections or getting hold of the407 #: currently logged in user. To register a function here, use the408 #: :meth:`after_request` decorator.409 self.after_request_funcs = {}410 411 #: A dictionary with lists of functions that are called after412 #: each request, even if an exception has occurred. The key of the413 #: dictionary is the name of the blueprint this function is active for,414- #: `None` for all requests. These functions are not allowed to modify414+ #: ``None`` for all requests. These functions are not allowed to modify415 #: the request, and their return values are ignored. If an exception416 #: occurred while processing the request, it gets passed to each417 #: teardown_request function. To register a function here, use the418 #: :meth:`teardown_request` decorator.11 unmodified lines430 431 #: A dictionary with lists of functions that can be used as URL432 #: value processor functions. Whenever a URL is built these functions433 #: are called to modify the dictionary of values in place. The key434- #: `None` here is used for application wide434+ #: ``None`` here is used for application wide435 #: callbacks, otherwise the key is the name of the blueprint.436 #: Each of these functions has the chance to modify the dictionary437 #:438 #: .. versionadded:: 0.7439 self.url_value_preprocessors = {}440 441 #: A dictionary with lists of functions that can be used as URL value442- #: preprocessors. The key `None` here is used for application wide442+ #: preprocessors. The key ``None`` here is used for application wide443 #: callbacks, otherwise the key is the name of the blueprint.444 #: Each of these functions has the chance to modify the dictionary445 #: of URL values before they are used as the keyword arguments of the446 #: view function. For each function registered this one should also4 unmodified lines451 self.url_default_functions = {}452 453 #: A dictionary with list of functions that are called without argument454 #: to populate the template context. The key of the dictionary is the455- #: name of the blueprint this function is active for, `None` for all455+ #: name of the blueprint this function is active for, ``None`` for all456 #: requests. Each returns a dictionary that the template context is457 #: updated with. To register a function here, use the458 #: :meth:`context_processor` decorator.459 self.template_context_processors = {151 unmodified lines611 return self.create_jinja_environment()612 613 @property614 def got_first_request(self):615- """This attribute is set to `True` if the application started615+ """This attribute is set to ``True`` if the application started616 handling the first request.617 618 .. versionadded:: 0.8619 """94 unmodified lines714 :meth:`create_jinja_environment` instead.715 """716 717 def select_jinja_autoescape(self, filename):718- """Returns `True` if autoescaping should be active for the given718+ """Returns ``True`` if autoescaping should be active for the given719 template name.720 721 .. versionadded:: 0.5722 """58 unmodified lines781 Flask will suppress any server error with a generic error page782 unless it is in debug mode. As such to enable just the783 interactive debugger without the code reloading, you have to784 invoke :meth:`run` with ``debug=True`` and ``use_reloader=False``.785- Setting ``use_debugger`` to `True` without being in debug mode785+ Setting ``use_debugger`` to ``True`` without being in debug mode786 won't catch any exceptions because there won't be any to787 catch.788 789 .. versionchanged:: 0.10311 unmodified lines1101 Setting error handlers via assignments to :attr:`error_handler_spec`1102 however is discouraged as it requires fiddling with nested dictionaries1103 and the special case for arbitrary exception types.1104 1105- The first `None` refers to the active blueprint. If the error1106- handler should be application wide `None` shall be used.1105+ The first ``None`` refers to the active blueprint. If the error1106+ handler should be application wide ``None`` shall be used.1107 1108 .. versionadded:: 0.71109 Use :meth:`register_error_handler` instead of modifying1110 :attr:`error_handler_spec` directly, for application wide error280 unmodified lines1391 return handler(e)1392 1393 def trap_http_exception(self, e):1394 """Checks if an HTTP exception should be trapped or not. By default1395- this will return `False` for all exceptions except for a bad request1396- key error if ``TRAP_BAD_REQUEST_ERRORS`` is set to `True`. It1397- also returns `True` if ``TRAP_HTTP_EXCEPTIONS`` is set to `True`.1395+ this will return ``False`` for all exceptions except for a bad request1396+ key error if ``TRAP_BAD_REQUEST_ERRORS`` is set to ``True``. It1397+ also returns ``True`` if ``TRAP_HTTP_EXCEPTIONS`` is set to ``True``.1398 1399 This is called for all HTTP exceptions raised by a view function.1400- If it returns `True` for any exception the error handler for this1400+ If it returns ``True`` for any exception the error handler for this1401 exception is not called and it shows up as regular exception in the1402 traceback. This is helpful for debugging implicitly raised HTTP1403 exceptions.1404 178 unmodified lines1583 1584 def should_ignore_error(self, error):1585 """This is called to figure out if an error should be ignored1586 or not as far as the teardown system is concerned. If this1587- function returns `True` then the teardown handlers will not be1587+ function returns ``True`` then the teardown handlers will not be1588 passed the error.1589 1590 .. versionadded:: 0.101591 """318 unmodified linesmodified:flask/blueprints.py+1 added-1 removed
40 unmodified lines41 subdomain = self.options.get('subdomain')42 if subdomain is None:43 subdomain = self.blueprint.subdomain44 45- #: The subdomain that the blueprint should be active for, `None`45+ #: The subdomain that the blueprint should be active for, ``None``46 #: otherwise.47 self.subdomain = subdomain48 49 url_prefix = self.options.get('url_prefix')365 unmodified linesmodified:flask/config.py+4 added-4 removed
91 unmodified lines92 93 app.config.from_pyfile(os.environ['YOURAPPLICATION_SETTINGS'])94 95 :param variable_name: name of the environment variable96- :param silent: set to `True` if you want silent failure for missing96+ :param silent: set to ``True`` if you want silent failure for missing97 files.98- :return: bool. `True` if able to load config, `False` otherwise.98+ :return: bool. ``True`` if able to load config, ``False`` otherwise.99 """100 rv = os.environ.get(variable_name)101 if not rv:102 if silent:12 unmodified lines115 116 :param filename: the filename of the config. This can either be an117 absolute filename or a filename relative to the118 root path.119- :param silent: set to `True` if you want silent failure for missing119+ :param silent: set to ``True`` if you want silent failure for missing120 files.121 122 .. versionadded:: 0.7123 `silent` parameter.48 unmodified lines172 173 :param filename: the filename of the JSON file. This can either be an174 absolute filename or a filename relative to the175 root path.176- :param silent: set to `True` if you want silent failure for missing176+ :param silent: set to ``True`` if you want silent failure for missing177 files.178 179 .. versionadded:: 1.0180 """78 unmodified linesmodified:flask/ctx.py+1 added-1 removed
208 unmodified lines209 for you. In debug mode the request context is kept around if210 exceptions happen so that interactive debuggers have a chance to211 introspect the data. With 0.4 this can also be forced for requests212 that did not fail and outside of `DEBUG` mode. By setting213- ``'flask._preserve_context'`` to `True` on the WSGI environment the213+ ``'flask._preserve_context'`` to ``True`` on the WSGI environment the214 context will not pop itself at the end of the request. This is used by215 the :meth:`~flask.Flask.test_client` for example to implement the216 deferred cleanup functionality.217 178 unmodified linesmodified:flask/helpers.py+14 added-14 removed
186 unmodified lines187 """Generates a URL to the given endpoint with the method provided.188 189 Variable arguments that are unknown to the target endpoint are appended190 to the generated URL as query arguments. If the value of a query argument191- is `None`, the whole pair is skipped. In case blueprints are active191+ is ``None``, the whole pair is skipped. In case blueprints are active192 you can shortcut references to the same blueprint by prefixing the193 local endpoint with a dot (``.``).194 195 This will reference the index function local to the current blueprint::6 unmodified lines202 errors through :attr:`Flask.url_build_error_handlers`. The `url_for`203 function results in a :exc:`~werkzeug.routing.BuildError` when the current204 app does not have a URL for the given endpoint and values. When it does, the205 :data:`~flask.current_app` calls its :attr:`~Flask.url_build_error_handlers` if206- it is not `None`, which can return a string to use as the result of206+ it is not ``None``, which can return a string to use as the result of207 `url_for` (instead of `url_for`'s default to raise the208 :exc:`~werkzeug.routing.BuildError` exception) or re-raise the exception.209 An example::210 32 unmodified lines243 :exc:`~werkzeug.routing.BuildError`.244 245 :param endpoint: the endpoint of the URL (name of the function)246 :param values: the variable arguments of the URL rule247- :param _external: if set to `True`, an absolute URL is generated. Server247+ :param _external: if set to ``True``, an absolute URL is generated. Server248 address can be changed via `SERVER_NAME` configuration variable which249 defaults to `localhost`.250 :param _scheme: a string specifying the desired URL scheme. The `_external`251- parameter must be set to `True` or a `ValueError` is raised. The default251+ parameter must be set to ``True`` or a `ValueError` is raised. The default252 behavior uses the same scheme as the current request, or253 ``PREFERRED_URL_SCHEME`` from the :ref:`app configuration <config>` if no254 request context is available. As of Werkzeug 0.10, this also can be set255 to an empty string to build protocol-relative URLs.119 unmodified lines375 def get_flashed_messages(with_categories=False, category_filter=[]):376 """Pulls all flashed messages from the session and returns them.377 Further calls in the same request to the function will return378 the same messages. By default just the messages are returned,379- but when `with_categories` is set to `True`, the return value will379+ but when `with_categories` is set to ``True``, the return value will380 be a list of tuples in the form ``(category, message)`` instead.381 382 Filter the flashed messages to one or more categories by providing those383 categories in `category_filter`. This allows rendering categories in384 separate html blocks. The `with_categories` and `category_filter`385 arguments are distinct:386 387 * `with_categories` controls whether categories are returned with message388- text (`True` gives a tuple, where `False` gives just the message text).388+ text (``True`` gives a tuple, where ``False`` gives just the message text).389 * `category_filter` filters the messages down to only those matching the390 provided categories.391 392 See :ref:`message-flashing-pattern` for examples.3 unmodified lines396 397 .. versionchanged:: 0.9398 `category_filter` parameter added.399 400- :param with_categories: set to `True` to also receive categories.400+ :param with_categories: set to ``True`` to also receive categories.401 :param category_filter: whitelist of categories to limit return values402 """403 flashes = _request_ctx_stack.top.flashes404 if flashes is None:53 unmodified lines458 that the file pointer is positioned at the start459 of data to send before calling :func:`send_file`.460 :param mimetype: the mimetype of the file if provided, otherwise461 auto detection happens.462- :param as_attachment: set to `True` if you want to send this file with462+ :param as_attachment: set to ``True`` if you want to send this file with463 a ``Content-Disposition: attachment`` header.464 :param attachment_filename: the filename for the attachment if it465 differs from the file's filename.466- :param add_etags: set to `False` to disable attaching of etags.467- :param conditional: set to `True` to enable conditional responses.466+ :param add_etags: set to ``False`` to disable attaching of etags.467+ :param conditional: set to ``True`` to enable conditional responses.468 469- :param cache_timeout: the timeout in seconds for the headers. When `None`469+ :param cache_timeout: the timeout in seconds for the headers. When ``None``470 (default), this value is set by471 :meth:`~Flask.get_send_file_max_age` of472 :data:`~flask.current_app`.473 """309 unmodified lines783 #: The name of the package or module. Do not change this once784 #: it was set by the constructor.785 self.import_name = import_name786 787- #: location of the templates. `None` if templates should not be787+ #: location of the templates. ``None`` if templates should not be788 #: exposed.789 self.template_folder = template_folder790 791 if root_path is None:25 unmodified lines817 del _get_static_url_path, _set_static_url_path818 819 @property820 def has_static_folder(self):821- """This is `True` if the package bound object's container has a821+ """This is ``True`` if the package bound object's container has a822 folder named ``'static'``.823 824 .. versionadded:: 0.5825 """16 unmodified lines842 the configuration of :data:`~flask.current_app`.843 844 Static file functions such as :func:`send_from_directory` use this845 function, and :func:`send_file` calls this function on846- :data:`~flask.current_app` when the given cache_timeout is `None`. If a846+ :data:`~flask.current_app` when the given cache_timeout is ``None``. If a847 cache_timeout is given in :func:`send_file`, that timeout is used;848 otherwise, this method is called.849 850 This allows subclasses to change the behavior when sending files based53 unmodified linesmodified:flask/sessions.py+9 added-9 removed
40 unmodified lines41 del _get_permanent, _set_permanent42 43 #: some session backends can tell you if a session is new, but that is44 #: not necessarily guaranteed. Use with caution. The default mixin45- #: implementation just hardcodes `False` in.45+ #: implementation just hardcodes ``False`` in.46 new = False47 48- #: for some backends this will always be `True`, but some backends will48+ #: for some backends this will always be ``True``, but some backends will49 #: default this to false and detect changes in the dictionary for as50 #: long as changes do not happen on mutable structures in the session.51- #: The default mixin implementation just hardcodes `True` in.51+ #: The default mixin implementation just hardcodes ``True`` in.52 modified = True53 54 55 def _tag(value):92 unmodified lines148 149 class Session(dict, SessionMixin):150 pass151 152- If :meth:`open_session` returns `None` Flask will call into152+ If :meth:`open_session` returns ``None`` Flask will call into153 :meth:`make_null_session` to create a session that acts as replacement154 if the session support cannot work because some requirement is not155 fulfilled. The default :class:`NullSession` class that is created156 will complain that the secret key was not set.70 unmodified lines227 def get_cookie_path(self, app):228 """Returns the path for which the cookie should be valid. The229 default implementation uses the value from the ``SESSION_COOKIE_PATH``230 config var if it's set, and falls back to ``APPLICATION_ROOT`` or231- uses ``/`` if it's `None`.231+ uses ``/`` if it's ``None``.232 """233 return app.config['SESSION_COOKIE_PATH'] or \234 app.config['APPLICATION_ROOT'] or '/'235 11 unmodified lines247 return app.config['SESSION_COOKIE_SECURE']248 249 def get_expiration_time(self, app, session):250 """A helper method that returns an expiration date for the session251- or `None` if the session is linked to the browser session. The251+ or ``None`` if the session is linked to the browser session. The252 default implementation returns now + the permanent session253 lifetime configured on the application.254 """255 if session.permanent:3 unmodified lines259 """Indicates whether a cookie should be set now or not. This is260 used by session backends to figure out if they should emit a261 set-cookie header or not. The default behavior is controlled by262 the ``SESSION_REFRESH_EACH_REQUEST`` config variable. If263- it's set to `False` then a cookie is only set if the session is264- modified, if set to `True` it's always set if the session is263+ it's set to ``False`` then a cookie is only set if the session is264+ modified, if set to ``True`` it's always set if the session is265 permanent.266 267 This check is usually skipped if sessions get deleted.268 4 unmodified lines273 save_each = app.config['SESSION_REFRESH_EACH_REQUEST']274 return save_each and session.permanent275 276 def open_session(self, app, request):277- """This method has to be implemented and must either return `None`277+ """This method has to be implemented and must either return ``None``278 in case the loading failed because of a configuration error or an279 instance of a session object which implements a dictionary like280 interface + the methods and attributes on :class:`SessionMixin`.281 """84 unmodified linesmodified:flask/wrappers.py+7 added-7 removed
45 unmodified lines46 #: .. versionadded:: 0.647 url_rule = None48 49 #: A dict of view arguments that matched the request. If an exception50- #: happened when matching, this will be `None`.50+ #: happened when matching, this will be ``None``.51 view_args = None52 53 #: If matching the URL failed, this is the exception that will be54 #: raised / was raised as part of the request handling. This is16 unmodified lines71 def endpoint(self):72 """The endpoint that matched the request. This in combination with73 :attr:`view_args` can be used to reconstruct the same or a74 modified URL. If an exception happened when matching, this will75- be `None`.75+ be ``None``.76 """77 if self.url_rule is not None:78 return self.url_rule.endpoint79 18 unmodified lines98 99 @property100 def json(self):101 """If the mimetype is `application/json` this will contain the102- parsed JSON data. Otherwise this will be `None`.102+ parsed JSON data. Otherwise this will be ``None``.103 104 The :meth:`get_json` method should be used instead.105 """106 from warnings import warn22 unmodified lines129 request object will be invoked. By default this function will130 only load the json data if the mimetype is ``application/json``131 but this can be overridden by the `force` parameter.132 133- :param force: if set to `True` the mimetype is ignored.134- :param silent: if set to `True` this method will fail silently135- and return `None`.136- :param cache: if set to `True` the parsed JSON data is remembered133+ :param force: if set to ``True`` the mimetype is ignored.134+ :param silent: if set to ``True`` this method will fail silently135+ and return ``None``.136+ :param cache: if set to ``True`` the parsed JSON data is remembered137 on the request.138 """139 rv = getattr(self, '_cached_json', _missing)140 if rv is not _missing:61 unmodified linesmodified:CHANGES+5 added-5 removed
10 unmodified lines11 - Added `**kwargs` to :meth:`flask.Test.test_client` to support passing12 additional keyword arguments to the constructor of13 :attr:`flask.Flask.test_client_class`.14 - Added ``SESSION_REFRESH_EACH_REQUEST`` config key that controls the15- set-cookie behavior. If set to `True` a permanent session will be15+ set-cookie behavior. If set to ``True`` a permanent session will be16 refreshed each request and get their lifetime extended, if set to17- `False` it will only be modified if the session actually modifies.17+ ``False`` it will only be modified if the session actually modifies.18 Non permanent sessions are not affected by this and will always19 expire if the browser window closes.20 - Made Flask support custom JSON mimetypes for incoming data.21 - Added support for returning tuples in the form ``(response, headers)``160 unmodified lines182 - Logger now only returns the debug log setting if it was not set183 explicitly.184 - Unregister a circular dependency between the WSGI environment and185 the request object when shutting down the request. This means that186- environ ``werkzeug.request`` will be `None` after the response was186+ environ ``werkzeug.request`` will be ``None`` after the response was187 returned to the WSGI server but has the advantage that the garbage188 collector is not needed on CPython to tear down the request unless189 the user created circular dependencies themselves.190 - Session is now stored after callbacks so that if the session payload12 unmodified lines203 :meth:`flask.Blueprint.add_app_template_filter`.204 - The :func:`flask.get_flashed_messages` function now allows rendering flashed205 message categories in separate blocks, through a ``category_filter``206 argument.207-- The :meth:`flask.Flask.run` method now accepts `None` for `host` and `port`208- arguments, using default values when `None`. This allows for calling run207+- The :meth:`flask.Flask.run` method now accepts ``None`` for `host` and `port`208+ arguments, using default values when ``None``. This allows for calling run209 using configuration values, e.g. ``app.run(app.config.get('MYHOST'),210 app.config.get('MYPORT'))``, with proper behavior whether or not a config211 file is provided.212 - The :meth:`flask.render_template` method now accepts a either an iterable of326 unmodified lines