Jump to >

This documentation covers Djblets 2.0. You can see the latest Djblets documentation or all other versions.

djblets.siteconfig.django_settings

Utilities for going between SiteConfiguration and Django settings.

get_django_settings_map()[source]

Return a map of customizable Django settings.

These maps are passed to other functions, like generate_defaults() and apply_django_settings(). Consumers can make their own settings map based on this with additional settings they want to provide.

Each entry maps a siteconfig settings key to either a Django settings key or detailed information on serializing/deserializing a Django setting.

An entry with detailed information represents that as a dictionary containing the following fields:

key (unicode):
The Django settings key.
deserialize_func (callable, optional):
A function taking the value from the siteconfig and returning a value usable in Django settings.
setter (callable, optional):
A function taking the Django settings object, the Django settings key, and the new value from the siteconfig (after going through deserialize_func, if provided). This will set the value in Django’s settings object.
Returns:The resulting settings map. This is generated once and cached for future calls.
Return type:dict
generate_defaults(settings_map)[source]

Return a dictionary of siteconfig defaults for Django settings.

This will iterate through the provided settings map and return a dictionary mapping a siteconfig settings key to the value from Django’s settings (if one is found).

Parameters:settings_map (dict) – A settings map, generated from get_django_settings_map() or a similar function.
Returns:A dictionary of siteconfig defaults.
Return type:dict
get_locale_defaults()[source]

Return a dictionary of siteconfig defaults for Django locale settings.

The generated defaults are specific to the values in locale_settings_map.

Returns:A dictionary of siteconfig defaults.
Return type:dict
get_mail_defaults()[source]

Return a dictionary of siteconfig defaults for Django e-mail settings.

The generated defaults are specific to the values in mail_settings_map.

Returns:A dictionary of siteconfig defaults.
Return type:dict
get_site_defaults()[source]

Return a dictionary of siteconfig defaults for Django site settings.

The generated defaults are specific to the values in site_settings_map.

Returns:A dictionary of siteconfig defaults.
Return type:dict
get_cache_defaults()[source]

Return a dictionary of siteconfig defaults for Django caching settings.

The generated defaults are specific to the values in cache_settings_map.

Returns:A dictionary of siteconfig defaults.
Return type:dict
get_django_defaults()[source]

Return a dictionary of siteconfig defaults for Django settings.

The generated defaults are specific to the values returned by get_django_settings_map().

Returns:A dictionary of siteconfig defaults.
Return type:dict
apply_django_settings(siteconfig, settings_map=None)[source]

Apply Django settings stored in the site configuration.

This takes a siteconfiguration storing Django settings and a settings map, applying each of the settings to Django. Setting will generally be stored in the Django settings object, but some settings will be specially applied based on their rules in the settings map.

Parameters: