docs: `True, False and None`

This commit is contained in:
defuz 2014-11-05 06:04:58 +03:00
parent 6dbb015b43
commit 8284217593
19 changed files with 99 additions and 99 deletions

View file

@ -135,7 +135,7 @@ class Flask(_PackageBoundObject):
By default the folder ``'instance'`` next to the
package or module is assumed to be the instance
path.
:param instance_relative_config: if set to `True` relative filenames
:param instance_relative_config: if set to ``True`` relative filenames
for loading the config are assumed to
be relative to the instance path instead
of the application root.
@ -193,16 +193,16 @@ class Flask(_PackageBoundObject):
#: .. versionadded:: 1.0
config_class = Config
#: The debug flag. Set this to `True` to enable debugging of the
#: The debug flag. Set this to ``True`` to enable debugging of the
#: application. In debug mode the debugger will kick in when an unhandled
#: exception occurs and the integrated server will automatically reload
#: the application if changes in the code are detected.
#:
#: This attribute can also be configured from the config with the `DEBUG`
#: configuration key. Defaults to `False`.
#: configuration key. Defaults to ``False``.
debug = ConfigAttribute('DEBUG')
#: The testing flag. Set this to `True` to enable the test mode of
#: The testing flag. Set this to ``True`` to enable the test mode of
#: Flask extensions (and in the future probably also Flask itself).
#: For example this might activate unittest helpers that have an
#: additional runtime cost which should not be enabled by default.
@ -211,7 +211,7 @@ class Flask(_PackageBoundObject):
#: default it's implicitly enabled.
#:
#: This attribute can also be configured from the config with the
#: `TESTING` configuration key. Defaults to `False`.
#: `TESTING` configuration key. Defaults to ``False``.
testing = ConfigAttribute('TESTING')
#: If a secret key is set, cryptographic components can use this to
@ -219,7 +219,7 @@ class Flask(_PackageBoundObject):
#: when you want to use the secure cookie for instance.
#:
#: This attribute can also be configured from the config with the
#: `SECRET_KEY` configuration key. Defaults to `None`.
#: `SECRET_KEY` configuration key. Defaults to ``None``.
secret_key = ConfigAttribute('SECRET_KEY')
#: The secure cookie uses this for the name of the session cookie.
@ -245,7 +245,7 @@ class Flask(_PackageBoundObject):
#: .. versionadded:: 0.2
#:
#: This attribute can also be configured from the config with the
#: `USE_X_SENDFILE` configuration key. Defaults to `False`.
#: `USE_X_SENDFILE` configuration key. Defaults to ``False``.
use_x_sendfile = ConfigAttribute('USE_X_SENDFILE')
#: The name of the logger to use. By default the logger name is the
@ -364,11 +364,11 @@ class Flask(_PackageBoundObject):
# :attr:`error_handler_spec` shall be used now.
self._error_handlers = {}
#: A dictionary of all registered error handlers. The key is `None`
#: A dictionary of all registered error handlers. The key is ``None``
#: for error handlers active on the application, otherwise the key is
#: the name of the blueprint. Each key points to another dictionary
#: where the key is the status code of the http exception. The
#: special key `None` points to a list of tuples where the first item
#: special key ``None`` points to a list of tuples where the first item
#: is the class for the instance check and the second the error handler
#: function.
#:
@ -379,7 +379,7 @@ class Flask(_PackageBoundObject):
#: A list of functions that are called when :meth:`url_for` raises a
#: :exc:`~werkzeug.routing.BuildError`. Each function registered here
#: is called with `error`, `endpoint` and `values`. If a function
#: returns `None` or raises a `BuildError` the next function is
#: returns ``None`` or raises a `BuildError` the next function is
#: tried.
#:
#: .. versionadded:: 0.9
@ -387,7 +387,7 @@ class Flask(_PackageBoundObject):
#: A dictionary with lists of functions that should be called at the
#: beginning of the request. The key of the dictionary is the name of
#: the blueprint this function is active for, `None` for all requests.
#: the blueprint this function is active for, ``None`` for all requests.
#: This can for example be used to open database connections or
#: getting hold of the currently logged in user. To register a
#: function here, use the :meth:`before_request` decorator.
@ -402,7 +402,7 @@ class Flask(_PackageBoundObject):
#: A dictionary with lists of functions that should be called after
#: each request. The key of the dictionary is the name of the blueprint
#: this function is active for, `None` for all requests. This can for
#: this function is active for, ``None`` for all requests. This can for
#: example be used to open database connections or getting hold of the
#: currently logged in user. To register a function here, use the
#: :meth:`after_request` decorator.
@ -411,7 +411,7 @@ class Flask(_PackageBoundObject):
#: A dictionary with lists of functions that are called after
#: each request, even if an exception has occurred. The key of the
#: dictionary is the name of the blueprint this function is active for,
#: `None` for all requests. These functions are not allowed to modify
#: ``None`` for all requests. These functions are not allowed to modify
#: the request, and their return values are ignored. If an exception
#: occurred while processing the request, it gets passed to each
#: teardown_request function. To register a function here, use the
@ -431,7 +431,7 @@ class Flask(_PackageBoundObject):
#: A dictionary with lists of functions that can be used as URL
#: value processor functions. Whenever a URL is built these functions
#: are called to modify the dictionary of values in place. The key
#: `None` here is used for application wide
#: ``None`` here is used for application wide
#: callbacks, otherwise the key is the name of the blueprint.
#: Each of these functions has the chance to modify the dictionary
#:
@ -439,7 +439,7 @@ class Flask(_PackageBoundObject):
self.url_value_preprocessors = {}
#: A dictionary with lists of functions that can be used as URL value
#: preprocessors. The key `None` here is used for application wide
#: preprocessors. The key ``None`` here is used for application wide
#: callbacks, otherwise the key is the name of the blueprint.
#: Each of these functions has the chance to modify the dictionary
#: of URL values before they are used as the keyword arguments of the
@ -452,7 +452,7 @@ class Flask(_PackageBoundObject):
#: A dictionary with list of functions that are called without argument
#: to populate the template context. The key of the dictionary is the
#: name of the blueprint this function is active for, `None` for all
#: name of the blueprint this function is active for, ``None`` for all
#: requests. Each returns a dictionary that the template context is
#: updated with. To register a function here, use the
#: :meth:`context_processor` decorator.
@ -612,7 +612,7 @@ class Flask(_PackageBoundObject):
@property
def got_first_request(self):
"""This attribute is set to `True` if the application started
"""This attribute is set to ``True`` if the application started
handling the first request.
.. versionadded:: 0.8
@ -715,7 +715,7 @@ class Flask(_PackageBoundObject):
"""
def select_jinja_autoescape(self, filename):
"""Returns `True` if autoescaping should be active for the given
"""Returns ``True`` if autoescaping should be active for the given
template name.
.. versionadded:: 0.5
@ -782,7 +782,7 @@ class Flask(_PackageBoundObject):
unless it is in debug mode. As such to enable just the
interactive debugger without the code reloading, you have to
invoke :meth:`run` with ``debug=True`` and ``use_reloader=False``.
Setting ``use_debugger`` to `True` without being in debug mode
Setting ``use_debugger`` to ``True`` without being in debug mode
won't catch any exceptions because there won't be any to
catch.
@ -1102,8 +1102,8 @@ class Flask(_PackageBoundObject):
however is discouraged as it requires fiddling with nested dictionaries
and the special case for arbitrary exception types.
The first `None` refers to the active blueprint. If the error
handler should be application wide `None` shall be used.
The first ``None`` refers to the active blueprint. If the error
handler should be application wide ``None`` shall be used.
.. versionadded:: 0.7
Use :meth:`register_error_handler` instead of modifying
@ -1392,12 +1392,12 @@ class Flask(_PackageBoundObject):
def trap_http_exception(self, e):
"""Checks if an HTTP exception should be trapped or not. By default
this will return `False` for all exceptions except for a bad request
key error if ``TRAP_BAD_REQUEST_ERRORS`` is set to `True`. It
also returns `True` if ``TRAP_HTTP_EXCEPTIONS`` is set to `True`.
this will return ``False`` for all exceptions except for a bad request
key error if ``TRAP_BAD_REQUEST_ERRORS`` is set to ``True``. It
also returns ``True`` if ``TRAP_HTTP_EXCEPTIONS`` is set to ``True``.
This is called for all HTTP exceptions raised by a view function.
If it returns `True` for any exception the error handler for this
If it returns ``True`` for any exception the error handler for this
exception is not called and it shows up as regular exception in the
traceback. This is helpful for debugging implicitly raised HTTP
exceptions.
@ -1584,7 +1584,7 @@ class Flask(_PackageBoundObject):
def should_ignore_error(self, error):
"""This is called to figure out if an error should be ignored
or not as far as the teardown system is concerned. If this
function returns `True` then the teardown handlers will not be
function returns ``True`` then the teardown handlers will not be
passed the error.
.. versionadded:: 0.10

View file

@ -42,7 +42,7 @@ class BlueprintSetupState(object):
if subdomain is None:
subdomain = self.blueprint.subdomain
#: The subdomain that the blueprint should be active for, `None`
#: The subdomain that the blueprint should be active for, ``None``
#: otherwise.
self.subdomain = subdomain

View file

@ -93,9 +93,9 @@ class Config(dict):
app.config.from_pyfile(os.environ['YOURAPPLICATION_SETTINGS'])
:param variable_name: name of the environment variable
:param silent: set to `True` if you want silent failure for missing
:param silent: set to ``True`` if you want silent failure for missing
files.
:return: bool. `True` if able to load config, `False` otherwise.
:return: bool. ``True`` if able to load config, ``False`` otherwise.
"""
rv = os.environ.get(variable_name)
if not rv:
@ -116,7 +116,7 @@ class Config(dict):
:param filename: the filename of the config. This can either be an
absolute filename or a filename relative to the
root path.
:param silent: set to `True` if you want silent failure for missing
:param silent: set to ``True`` if you want silent failure for missing
files.
.. versionadded:: 0.7
@ -173,7 +173,7 @@ class Config(dict):
:param filename: the filename of the JSON file. This can either be an
absolute filename or a filename relative to the
root path.
:param silent: set to `True` if you want silent failure for missing
:param silent: set to ``True`` if you want silent failure for missing
files.
.. versionadded:: 1.0

View file

@ -210,7 +210,7 @@ class RequestContext(object):
exceptions happen so that interactive debuggers have a chance to
introspect the data. With 0.4 this can also be forced for requests
that did not fail and outside of `DEBUG` mode. By setting
``'flask._preserve_context'`` to `True` on the WSGI environment the
``'flask._preserve_context'`` to ``True`` on the WSGI environment the
context will not pop itself at the end of the request. This is used by
the :meth:`~flask.Flask.test_client` for example to implement the
deferred cleanup functionality.

View file

@ -188,7 +188,7 @@ def url_for(endpoint, **values):
Variable arguments that are unknown to the target endpoint are appended
to the generated URL as query arguments. If the value of a query argument
is `None`, the whole pair is skipped. In case blueprints are active
is ``None``, the whole pair is skipped. In case blueprints are active
you can shortcut references to the same blueprint by prefixing the
local endpoint with a dot (``.``).
@ -203,7 +203,7 @@ def url_for(endpoint, **values):
function results in a :exc:`~werkzeug.routing.BuildError` when the current
app does not have a URL for the given endpoint and values. When it does, the
:data:`~flask.current_app` calls its :attr:`~Flask.url_build_error_handlers` if
it is not `None`, which can return a string to use as the result of
it is not ``None``, which can return a string to use as the result of
`url_for` (instead of `url_for`'s default to raise the
:exc:`~werkzeug.routing.BuildError` exception) or re-raise the exception.
An example::
@ -244,11 +244,11 @@ def url_for(endpoint, **values):
:param endpoint: the endpoint of the URL (name of the function)
:param values: the variable arguments of the URL rule
:param _external: if set to `True`, an absolute URL is generated. Server
:param _external: if set to ``True``, an absolute URL is generated. Server
address can be changed via `SERVER_NAME` configuration variable which
defaults to `localhost`.
:param _scheme: a string specifying the desired URL scheme. The `_external`
parameter must be set to `True` or a `ValueError` is raised. The default
parameter must be set to ``True`` or a `ValueError` is raised. The default
behavior uses the same scheme as the current request, or
``PREFERRED_URL_SCHEME`` from the :ref:`app configuration <config>` if no
request context is available. As of Werkzeug 0.10, this also can be set
@ -376,7 +376,7 @@ def get_flashed_messages(with_categories=False, category_filter=[]):
"""Pulls all flashed messages from the session and returns them.
Further calls in the same request to the function will return
the same messages. By default just the messages are returned,
but when `with_categories` is set to `True`, the return value will
but when `with_categories` is set to ``True``, the return value will
be a list of tuples in the form ``(category, message)`` instead.
Filter the flashed messages to one or more categories by providing those
@ -385,7 +385,7 @@ def get_flashed_messages(with_categories=False, category_filter=[]):
arguments are distinct:
* `with_categories` controls whether categories are returned with message
text (`True` gives a tuple, where `False` gives just the message text).
text (``True`` gives a tuple, where ``False`` gives just the message text).
* `category_filter` filters the messages down to only those matching the
provided categories.
@ -397,7 +397,7 @@ def get_flashed_messages(with_categories=False, category_filter=[]):
.. versionchanged:: 0.9
`category_filter` parameter added.
:param with_categories: set to `True` to also receive categories.
:param with_categories: set to ``True`` to also receive categories.
:param category_filter: whitelist of categories to limit return values
"""
flashes = _request_ctx_stack.top.flashes
@ -459,14 +459,14 @@ def send_file(filename_or_fp, mimetype=None, as_attachment=False,
of data to send before calling :func:`send_file`.
:param mimetype: the mimetype of the file if provided, otherwise
auto detection happens.
:param as_attachment: set to `True` if you want to send this file with
:param as_attachment: set to ``True`` if you want to send this file with
a ``Content-Disposition: attachment`` header.
:param attachment_filename: the filename for the attachment if it
differs from the file's filename.
:param add_etags: set to `False` to disable attaching of etags.
:param conditional: set to `True` to enable conditional responses.
:param add_etags: set to ``False`` to disable attaching of etags.
:param conditional: set to ``True`` to enable conditional responses.
:param cache_timeout: the timeout in seconds for the headers. When `None`
:param cache_timeout: the timeout in seconds for the headers. When ``None``
(default), this value is set by
:meth:`~Flask.get_send_file_max_age` of
:data:`~flask.current_app`.
@ -784,7 +784,7 @@ class _PackageBoundObject(object):
#: it was set by the constructor.
self.import_name = import_name
#: location of the templates. `None` if templates should not be
#: location of the templates. ``None`` if templates should not be
#: exposed.
self.template_folder = template_folder
@ -818,7 +818,7 @@ class _PackageBoundObject(object):
@property
def has_static_folder(self):
"""This is `True` if the package bound object's container has a
"""This is ``True`` if the package bound object's container has a
folder named ``'static'``.
.. versionadded:: 0.5
@ -843,7 +843,7 @@ class _PackageBoundObject(object):
Static file functions such as :func:`send_from_directory` use this
function, and :func:`send_file` calls this function on
:data:`~flask.current_app` when the given cache_timeout is `None`. If a
:data:`~flask.current_app` when the given cache_timeout is ``None``. If a
cache_timeout is given in :func:`send_file`, that timeout is used;
otherwise, this method is called.

View file

@ -42,13 +42,13 @@ class SessionMixin(object):
#: some session backends can tell you if a session is new, but that is
#: not necessarily guaranteed. Use with caution. The default mixin
#: implementation just hardcodes `False` in.
#: implementation just hardcodes ``False`` in.
new = False
#: for some backends this will always be `True`, but some backends will
#: for some backends this will always be ``True``, but some backends will
#: default this to false and detect changes in the dictionary for as
#: long as changes do not happen on mutable structures in the session.
#: The default mixin implementation just hardcodes `True` in.
#: The default mixin implementation just hardcodes ``True`` in.
modified = True
@ -149,7 +149,7 @@ class SessionInterface(object):
class Session(dict, SessionMixin):
pass
If :meth:`open_session` returns `None` Flask will call into
If :meth:`open_session` returns ``None`` Flask will call into
:meth:`make_null_session` to create a session that acts as replacement
if the session support cannot work because some requirement is not
fulfilled. The default :class:`NullSession` class that is created
@ -228,7 +228,7 @@ class SessionInterface(object):
"""Returns the path for which the cookie should be valid. The
default implementation uses the value from the ``SESSION_COOKIE_PATH``
config var if it's set, and falls back to ``APPLICATION_ROOT`` or
uses ``/`` if it's `None`.
uses ``/`` if it's ``None``.
"""
return app.config['SESSION_COOKIE_PATH'] or \
app.config['APPLICATION_ROOT'] or '/'
@ -248,7 +248,7 @@ class SessionInterface(object):
def get_expiration_time(self, app, session):
"""A helper method that returns an expiration date for the session
or `None` if the session is linked to the browser session. The
or ``None`` if the session is linked to the browser session. The
default implementation returns now + the permanent session
lifetime configured on the application.
"""
@ -260,8 +260,8 @@ class SessionInterface(object):
used by session backends to figure out if they should emit a
set-cookie header or not. The default behavior is controlled by
the ``SESSION_REFRESH_EACH_REQUEST`` config variable. If
it's set to `False` then a cookie is only set if the session is
modified, if set to `True` it's always set if the session is
it's set to ``False`` then a cookie is only set if the session is
modified, if set to ``True`` it's always set if the session is
permanent.
This check is usually skipped if sessions get deleted.
@ -274,7 +274,7 @@ class SessionInterface(object):
return save_each and session.permanent
def open_session(self, app, request):
"""This method has to be implemented and must either return `None`
"""This method has to be implemented and must either return ``None``
in case the loading failed because of a configuration error or an
instance of a session object which implements a dictionary like
interface + the methods and attributes on :class:`SessionMixin`.

View file

@ -47,7 +47,7 @@ class Request(RequestBase):
url_rule = None
#: A dict of view arguments that matched the request. If an exception
#: happened when matching, this will be `None`.
#: happened when matching, this will be ``None``.
view_args = None
#: If matching the URL failed, this is the exception that will be
@ -72,7 +72,7 @@ class Request(RequestBase):
"""The endpoint that matched the request. This in combination with
:attr:`view_args` can be used to reconstruct the same or a
modified URL. If an exception happened when matching, this will
be `None`.
be ``None``.
"""
if self.url_rule is not None:
return self.url_rule.endpoint
@ -99,7 +99,7 @@ class Request(RequestBase):
@property
def json(self):
"""If the mimetype is `application/json` this will contain the
parsed JSON data. Otherwise this will be `None`.
parsed JSON data. Otherwise this will be ``None``.
The :meth:`get_json` method should be used instead.
"""
@ -130,10 +130,10 @@ class Request(RequestBase):
only load the json data if the mimetype is ``application/json``
but this can be overridden by the `force` parameter.
:param force: if set to `True` the mimetype is ignored.
:param silent: if set to `True` this method will fail silently
and return `None`.
:param cache: if set to `True` the parsed JSON data is remembered
:param force: if set to ``True`` the mimetype is ignored.
:param silent: if set to ``True`` this method will fail silently
and return ``None``.
:param cache: if set to ``True`` the parsed JSON data is remembered
on the request.
"""
rv = getattr(self, '_cached_json', _missing)