Improve settings definition in a namespace like fashion #109
Labels
triage/enhancement
New feature or request
triage/experimental
Something related to experimental features and/or package version
Instead of having weaver.ini settings names like
weaver.fancy_item_parameter
, which makes it hard to read and quite long, we could improve it to be as follows:This would achieve 2 goals :
1- separate the 'weaver' (or any other thing like mongo, caching, etc.) specific configurations into their relevant section.
2- leave the specific
app:main
andserver
specifications only to running the app (ie: pyramid config and eggs) to not pollute it with everything else.Will require to load the settings using:
For compatibility, we should plug the loaded config from ConfigParser into
registry.config
like follows (especially L21, don't need the other part as registry is accessible through request object):weaver/weaver/database/__init__.py
Lines 18 to 28 in 309a694
And the
get_setting
function should be improved to return aSettings(dict)
object that knows how to return the appropriate setting (ie:weaver.setting
would try all variants below), making it fairly transparent for the whole source code. TheSettings
class will have to hold references to the settings dictionary returned byregistry.get_settings()
(ie: pyramid-config[app:main]
values) and the other settings from various INI sections.To simplify the retrieval of settings,
ConfigBox
of https://pypi.org/project/python-box/ could be used.The text was updated successfully, but these errors were encountered: