dip.settings

The dip.settings module implements the infrastructure for application specific persistent storage typically used for user settings.

ISettings

class dip.settings.ISettings

Base class: Interface

The ISettings class defines the interface that should be implemented by an object, often a view, that reads and writes user settings.

id = Str()

The identifier of the setting.

restore(settings_manager)

Restore the settings obtained from a settings manager.

Parameters:settings_manager – is the settings manager.
save(settings_manager)

Save the settings to a settings manager.

Parameters:settings_manager – is the settings manager.

ISettingsManager

class dip.settings.ISettingsManager

Base class: Interface

The ISettingsManager interface defines the API of a settings manager.

load(organization, application=None)

Load the application’s settings.

Parameters:
  • organization – is the name of the organization. It is recommended that this is a FQDN.
  • application – is the name of the application. It will default to the base name of sys.argv[0] with any extension removed.
read_value(name)

Read the value of a setting.

Parameters:name – is the name of the setting.
Returns:the value of the setting, or None if there is no such setting.
restore(models)

Restore the settings for a sequence of models. If no settings have been loaded, i.e. load() has not been called, then this has no effect.

Parameters:models – is the sequence of models. Any model that does not implement ISettings is ignored.
save(models)

Save the settings for a sequence of models. If no settings have been loaded, i.e. load() has not been called, then this has no effect.

Parameters:models – is the sequence of models. Any model that does not implement ISettings is ignored.
write_value(name, value)

Write the value of a setting.

Parameters:
  • name – is the name of the setting.
  • value – is the value of the setting. If this is None then the setting is removed.

ISettingsStorage

class dip.settings.ISettingsStorage

Base class: Interface

The ISettingsStorage class defines the interface that should be implemented by storage used to hold settings.

begin_group(group)

Begin a group.

Parameters:group – is the name of the group.
end_group()

End the current group.

flush()

Ensure that all settings changes are written to persistent storage.

read_value(name)

Read the value of a setting.

Parameters:name – is the name of the setting.
Returns:the value of the setting, or None if there is no such setting.
write_value(name, value)

Write the value of a setting.

Parameters:
  • name – is the name of the setting.
  • value – is the value of the setting. If this is None then the setting is removed.

SettingsManager

class dip.settings.SettingsManager

Base class: Singleton

The SettingsManager class is a singleton that provides access to a default settings manager.

instance = Instance(ISettingsManager)

The settings manager instance.