Participer au site avec un Tip
Rechercher
 

Améliorations / Corrections

Vous avez des améliorations (ou des corrections) à proposer pour ce document : je vous remerçie par avance de m'en faire part, cela m'aide à améliorer le site.

Emplacement :

Description des améliorations :

Module « flask »

Classe « Config »

Informations générales

Héritage

builtins.object
    builtins.dict
        Config

Définition

class Config(builtins.dict):

Description [extrait de Config.__doc__]

Works exactly like a dict but provides ways to fill it from files
    or special dictionaries.  There are two common patterns to populate the
    config.

    Either you can fill the config from a config file::

        app.config.from_pyfile('yourconfig.cfg')

    Or alternatively you can define the configuration options in the
    module that calls :meth:`from_object` or provide an import path to
    a module that should be loaded.  It is also possible to tell it to
    use the same module and with that provide the configuration values
    just before the call::

        DEBUG = True
        SECRET_KEY = 'development key'
        app.config.from_object(__name__)

    In both cases (loading from any Python file or loading from modules),
    only uppercase keys are added to the config.  This makes it possible to use
    lowercase values in the config file for temporary values that are not added
    to the config or to define the config keys in the same file that implements
    the application.

    Probably the most interesting way to load configurations is from an
    environment variable pointing to a file::

        app.config.from_envvar('YOURAPPLICATION_SETTINGS')

    In this case before launching the application you have to set this
    environment variable to the file you want to use.  On Linux and OS X
    use the export statement::

        export YOURAPPLICATION_SETTINGS='/path/to/config/file'

    On windows use `set` instead.

    :param root_path: path to which files are read relative from.  When the
                      config object is created by the application, this is
                      the application's :attr:`~flask.Flask.root_path`.
    :param defaults: an optional dictionary of default values
    

Constructeur(s)

Signature du constructeur Description
__init__(self, root_path: str, defaults: Optional[dict] = None) -> None

Liste des opérateurs

Opérateurs hérités de la classe dict

__contains__, __delitem__, __eq__, __ge__, __getitem__, __gt__, __ior__, __le__, __lt__, __ne__, __or__, __ror__, __setitem__

Liste des opérateurs

Opérateurs hérités de la classe object

__eq__, __ge__, __gt__, __le__, __lt__, __ne__

Liste des méthodes

Toutes les méthodes Méthodes d'instance Méthodes statiques Méthodes dépréciées
Signature de la méthodeDescription
__class_getitem__ See PEP 585 [extrait de __class_getitem__.__doc__]
__repr__(self) -> str
from_envvar(self, variable_name: str, silent: bool = False) -> bool Loads a configuration from an environment variable pointing to [extrait de from_envvar.__doc__]
from_file(self, filename: str, load: Callable[[IO[Any]], Mapping], silent: bool = False) -> bool Update the values in the config from a file that is loaded [extrait de from_file.__doc__]
from_json(self, filename: str, silent: bool = False) -> bool Update the values in the config from a JSON file. The loaded [extrait de from_json.__doc__]
from_mapping(self, mapping: Optional[Mapping[str, Any]] = None, **kwargs: Any) -> bool Updates the config like :meth:`update` ignoring items with non-upper [extrait de from_mapping.__doc__]
from_object(self, obj: Union[object, str]) -> None Updates the values from the given object. An object can be of one [extrait de from_object.__doc__]
from_pyfile(self, filename: str, silent: bool = False) -> bool Updates the values in the config from a Python file. This function [extrait de from_pyfile.__doc__]
fromkeys(iterable, value=None) Create a new dictionary with keys from iterable and values set to value. [extrait de fromkeys.__doc__]
get_namespace(self, namespace: str, lowercase: bool = True, trim_namespace: bool = True) -> Dict[str, Any] Returns a dictionary containing a subset of configuration options [extrait de get_namespace.__doc__]

Méthodes héritées de la classe dict

__getattribute__, __init_subclass__, __iter__, __len__, __reversed__, __sizeof__, __subclasshook__, clear, copy, get, items, keys, pop, popitem, setdefault, update, values

Méthodes héritées de la classe object

__delattr__, __dir__, __format__, __getattribute__, __hash__, __init_subclass__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __str__, __subclasshook__