Browse Source

improved documentation for config.from_object (#1870)

pull/1867/merge
Jason Brazeal 9 years ago committed by David Lord
parent
commit
d88c08e56f
  1. 1
      docs/config.rst
  2. 11
      flask/config.py

1
docs/config.rst

@ -310,6 +310,7 @@ that experience:
limit yourself to request-only accesses to the configuration you can
reconfigure the object later on as needed.
.. _config-dev-prod:
Development / Production
------------------------

11
flask/config.py

@ -143,10 +143,12 @@ class Config(dict):
- 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.
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.
Just the uppercase variables in that object are stored in the config.
Example usage::
Example of module-based configuration::
app.config.from_object('yourapplication.default_config')
from yourapplication import default_config
@ -157,6 +159,9 @@ class Config(dict):
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, string_types):

Loading…
Cancel
Save