Provides SavedSettingsObject implementing settings-dict based property storage.

See Also : underlying property definitions


Property has been primed but has no user-set value, so use default/generator value.


Setup a framework for lazy saving and loading of .settings properties.

This is useful for BE objects with saved properties (e.g. BugDir, Bug, Comment). For example usage, consider the unittests at the end of the module.


clear_cached_setting([setting]) If setting=None, clear all cached settings
load_settings() Load the settings from disk.
save_settings() Save the settings to disk.

If setting=None, clear all cached settings


Load the settings from disk.


Save the settings to disk.


Property has not been primed (loaded)., name)

Convert SavedSettingsObject attribute names to .settings dict keys.


>>> print attr_name_to_setting_name(None, "user_id")

See also


The default action undertaken when an UNPRIMED property is accessed.

Attempt to run .load_settings(), which calls ._setup_saved_settings() internally. If .storage is inaccessible, don’t do anything., old, new)

The default action undertaken when a property changes., name)

Convert keys to the .settings dict into their associated SavedSettingsObject attribute names.

See also



>>> print setting_name_to_attr_name(None,"User-id")
user_id, doc, default=None, generator=None, change_hook=<function prop_save_settings at 0xa9d495c>, mutable=False, primer=<function prop_load_settings at 0xa9d4994>, allowed=None, check_fn=None, settings_properties=[], required_saved_properties=[], require_save=False)

Combine the common decorators in a single function.

Use zero or one (but not both) of default or generator, since a working default will keep the generator from functioning. Use the default if you know what you want the default value to be at ‘coding time’. Use the generator if you can write a function to determine a valid default at run time. If both default and generator are None, then the property will be a defaulting property which defaults to None.

allowed and check_fn have a similar relationship, although you can use both of these if you want. allowed compares the proposed value against a list determined at ‘coding time’ and check_fn allows more flexible comparisons to take place at run time.

Set require_save to True if you want to save the default/generated value for a property, to protect against future changes. E.g., we currently expect all comments to be ‘text/plain’ but in the future we may want to default to ‘text/html’. If we don’t want the old comments to be interpreted as ‘text/html’, we would require that the content type be saved.

change_hook, primer, settings_properties, and required_saved_properties are only options to get their defaults into our local scope. Don’t mess with them.

Set mutable=True if:

  • default is a mutable
  • your generator function may return mutables
  • you set change_hook and might have mutable property values

See the docstrings in for details on how each of these cases are handled.

The value stored in .settings[name] will be

  • no value (or UNPRIMED) if the property has been neither set, nor loaded as blank.
  • EMPTY if the value has been loaded as blank.
  • some value if the property has been either loaded or set.

Table Of Contents

Previous topic

This Page