Enable nested dictionary path keys for siteconfig settings.

Review Request #12814 — Created Jan. 26, 2023 and updated — Latest diff uploaded

Information

Djblets
release-3.x

Reviewers

SiteConfiguration.get() and .set() now support taking a list/tuple
of strings for a path when getting or setting a value in siteconfig
settings. This is used to manipulate settings within nested
dictionaries, making it easier and safer than pulling out a dictionary
and trying to replace it.

This is supported for stored settings and registered defaults. To make
this easier to manage, there's a new _UNSET value used for defaults,
and a couple helper functions to separate out stored setting retrieval
and default setting retrieval.

get() also now accepts an optional required argument, which will
raise a KeyError if a setting is not found in the configuration or
defaults. This can help callers distinguish actual None values from
missing/bad settings.

The management commands have been updated to take advantage of this,
simplifying that code and ensuring we have only one code path where we
update nested settings.

Upcoming changes will build on some of this work.

Unit tests passed.

Made use of the new key path support in some upcoming changes in
Review Board.

Tested the set-siteconfig and get-siteconfig management commands
to make sure they worked as before.

Commits

Files