Add narrative docs for app configuration
This commit is contained in:
parent
f9a7b41f94
commit
4641e24afd
11 changed files with 596 additions and 47 deletions
36
docs/narr/config/overview.rst
Normal file
36
docs/narr/config/overview.rst
Normal file
|
@ -0,0 +1,36 @@
|
|||
|
||||
Overview
|
||||
========
|
||||
|
||||
The app uses a global :term:`config object` to keep track of its
|
||||
:term:`config settings<config setting>`. See also :doc:`object`.
|
||||
|
||||
The app must call :func:`~wuttjamaican.conf.make_config()` during
|
||||
startup to obtain the config object.
|
||||
|
||||
Values come (mostly) from :term:`config files<config file>` and/or the
|
||||
:term:`settings table`. See also :doc:`settings`.
|
||||
|
||||
Values are always strings in their raw format, as returned by
|
||||
:meth:`~wuttjamaican.conf.WuttaConfig.get()`. But the config object
|
||||
also has methods to coerce values to various types, e.g.:
|
||||
|
||||
* :meth:`~wuttjamaican.conf.WuttaConfig.get_bool()`
|
||||
* :meth:`~wuttjamaican.conf.WuttaConfig.get_int()`
|
||||
* :meth:`~wuttjamaican.conf.WuttaConfig.get_list()`
|
||||
|
||||
The config object is also responsible for creating the :term:`app
|
||||
handler`::
|
||||
|
||||
from wuttjamaican.conf import make_config
|
||||
|
||||
config = make_config()
|
||||
app = config.get_app()
|
||||
|
||||
if config.get_bool('foo.bar'):
|
||||
print('YES for foo.bar')
|
||||
else:
|
||||
print('NO for foo.bar')
|
||||
|
||||
with app.short_session() as session:
|
||||
print(session.bind)
|
Loading…
Add table
Add a link
Reference in a new issue