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

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

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.

Summary ID
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.
104c32840c609b88e64e031c89d7fd501a580972
Description From Last Updated

This doesn't need the parens (unless we want to do that in this case, but the previous function didn't).

chipx86chipx86

This needs a Version Added and the main docstring needs a Version Changed.

chipx86chipx86

Let's pull self.siteconfig out into a local variable. We use it in almost every statement.

chipx86chipx86
chipx86
  1. Looks great!

  2. djblets/siteconfig/models.py (Diff revision 1)
     
     
    Show all issues

    This doesn't need the parens (unless we want to do that in this case, but the previous function didn't).

  3. djblets/siteconfig/models.py (Diff revision 1)
     
     
     
    Show all issues

    This needs a Version Added and the main docstring needs a Version Changed.

  4. 
      
david
maubin
  1. Ship It!
  2. 
      
chipx86
  1. 
      
  2. djblets/siteconfig/tests.py (Diff revision 2)
     
     
    Show all issues

    Let's pull self.siteconfig out into a local variable. We use it in almost every statement.

  3. 
      
david
Review request changed
Status:
Completed
Change Summary:
Pushed to release-5.x (be914b5)