djblets.extensions.settings¶
Settings API for extensions.
- class ExtensionSettings(extension)[source]¶
Bases:
dict
Settings data for an extension.
This is a glorified dictionary that acts as a proxy for the extension’s stored settings in the database.
Callers must call
save()
when they want to make the settings persistent.If a key is not found in the dictionary,
Extension.default_settings
will be checked as well.- __init__(extension)[source]¶
Initialize and load the settings.
- Parameters:
extension (
djblets.extensions.extension.Extension
) – The extension the settings is for.
- __getitem__(key)[source]¶
Retrieve an item from the dictionary.
This will attempt to return a default value from
Extension.default_settings
if the setting has not been set.
- __contains__(key)[source]¶
Return if a setting can be found.
This will check both the stored settings and the default settings for the extension.
- get(key, default=None)[source]¶
Return the value for a setting.
This will return a value from either the stored settings, the extensin’s default settings, or the value passed as
default
.
- Settings[source]¶
Legacy name for ExtensionSettings.
This is unlikely to be needed outside of the Djblets Extensions code, but is available for any callers who might be dependent on it.
Deprecated since version 2.0: Renamed to
ExtensionSettings
. This will be removed in Djblets 3.0.