I have used parsing '__file__' to get at a custom section 'archive'
used by a backup routine (read-only database credentials).
I'm now moving more and more things into environment variables, which
are more Docker Compose and CI (Continuous Integration) friendly when
different deployments need different configurations. I've got a
general routine called from 'main()' that looks for variables like
'APPNAME__sqlalchemy__url' and overwrite the corresponding setting
('sqlalchemy.url').I had to use double underscores because dots aren't
allowed in environment variable names. The initial double underscore
is to distinguish "APPNAME__foo" (an envvar overriding an arbitrary
setting) from "APPNAME_FOO" (an envvar used for a non-setting
purpose). I didn't want to count on upper/lowercase recognition or
translation.
Longer-term I'm debating whether to switch to a JSON file or go
completely to default values overriden by envvars. The reason I
haven't yet is there are some fifty settings, some for middleware, and
some that would be split (e.g., four unchanging settings plus one or
two deployment-specific/secret settings): I don't want to put the
entire group into envvars, but at the same time I don't want to split
the group either. So I've kept the INI file until I feel more certain.
(But the INI file has only the '[app:main]" section, parsed by
'pyramid.paster.get_appsettings()'. The logging configuration is a
separate INI file parsed by 'logging.config.fileConfig()'.
> To view this discussion visit
https://groups.google.com/d/msgid/pylons-discuss/66c7bab8-34fc-4b94-9085-a14fcffbf339n%40googlegroups.com.
--
Mike Orr <
slugg...@gmail.com>