Home / Function/ from_object() — flask Function Reference

from_object() — flask Function Reference

Architecture documentation for the from_object() function in config.py from the flask codebase.

Entity Profile

Dependency Diagram

graph TD
  e968f33d_fca8_c3ea_6616_3fcd3d3dd07c["from_object()"]
  1e067a59_9e9f_8edb_0434_65b5c5690e36["Config"]
  e968f33d_fca8_c3ea_6616_3fcd3d3dd07c -->|defined in| 1e067a59_9e9f_8edb_0434_65b5c5690e36
  992a2a65_31c4_7dbd_d0e9_54f209631cda["from_pyfile()"]
  992a2a65_31c4_7dbd_d0e9_54f209631cda -->|calls| e968f33d_fca8_c3ea_6616_3fcd3d3dd07c
  style e968f33d_fca8_c3ea_6616_3fcd3d3dd07c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/flask/config.py lines 218–254

    def from_object(self, obj: object | str) -> None:
        """Updates the values from the given object.  An object can be of one
        of the following two types:

        -   a string: in this case the object with that name will be imported
        -   an actual object reference: that object is used directly

        Objects are usually either modules or classes. :meth:`from_object`
        loads only the uppercase attributes of the module/class. A ``dict``
        object will not work with :meth:`from_object` because the keys of a
        ``dict`` are not attributes of the ``dict`` class.

        Example of module-based configuration::

            app.config.from_object('yourapplication.default_config')
            from yourapplication import default_config
            app.config.from_object(default_config)

        Nothing is done to the object before loading. If the object is a
        class and has ``@property`` attributes, it needs to be
        instantiated before being passed to this method.

        You should not use this function to load the actual configuration but
        rather configuration defaults.  The actual config should be loaded
        with :meth:`from_pyfile` and ideally from a location not within the
        package because the package might be installed system wide.

        See :ref:`config-dev-prod` for an example of class-based configuration
        using :meth:`from_object`.

        :param obj: an import name or object
        """
        if isinstance(obj, str):
            obj = import_string(obj)
        for key in dir(obj):
            if key.isupper():
                self[key] = getattr(obj, key)

Subdomains

Defined In

Called By

Frequently Asked Questions

What does from_object() do?
from_object() is a function in the flask codebase, defined in src/flask/config.py.
Where is from_object() defined?
from_object() is defined in src/flask/config.py at line 218.
What calls from_object()?
from_object() is called by 1 function(s): from_pyfile.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free