Add support for config layers to SiteConfiguration.get().

Review Request #14431 — Created May 9, 2025 and submitted — Latest diff uploaded

Information

Djblets
release-5.x

Reviewers

This change adds a new layers argument to SiteConfiguration.get().
This allows passing in a list of additional settings dictionaries, which
will be checked before the main settings dict and defaults dicts.

Callers can use this to add overrides for specific keys: for example,
one might want to have a global setting for the server, a setting for
tenant accounts, and even a user setting for individual users. This
would be accomplished by passing in
layers=[user_settings, tenant_settings].

This also does some additional cleanup and typing for surrounding code,
reducing the noise I saw in my editor.

Ran unit tests.

Diff Revision 1

This is not the most recent revision of the diff. The latest diff is revision 2. See what's changed.

orig
1
2

Commits

First Last Summary ID Author
Add support for config layers to SiteConfiguration.get().
This change adds a new `layers` argument to `SiteConfiguration.get()`. This allows passing in a list of additional settings dictionaries, which will be checked before the main settings dict and defaults dicts. Callers can use this to add overrides for specific keys: for example, one might want to have a global setting for the server, a setting for tenant accounts, and even a user setting for individual users. This would be accomplished by passing in `layers=[user_settings, tenant_settings]`. This also does some additional cleanup and typing for surrounding code, reducing the noise I saw in my editor. Testing Done: Ran unit tests.
f6017c457ab736202a0f550e5d11d980a871343f David Trowbridge
djblets/siteconfig/managers.py
djblets/siteconfig/models.py
djblets/siteconfig/tests.py
Loading...