Jump to >

djblets.extensions.settings

class ExtensionSettings(extension)[source]

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.

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.

Parameters
  • key (unicode) – The key to retrieve.

  • default (object, optional) – The default value, if it couldn’t be found in the stored settings or the extension’s default settings.

Returns

The value for the setting.

Return type

object

set(key, value)[source]

Set a setting’s value.

This is equivalent to setting the value through standard dictionary attribute storage.

Parameters
  • key (unicode) – The key to set.

  • value (object) – The value for the setting.

load()[source]

Load the settings from the database.

save()[source]

Save all current settings to the database.

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.