djangofloor.conf.providers

Providers of Django settings

Settings that are merged to provide the final Django settings come from different kinds of sources (Python modules or files, ini files, …).

class djangofloor.conf.providers.ConfigFieldsProvider[source]

Provides a list of djangofloor.conf.fields.ConfigField. Used for retrieving settings from a config file.

get_config_fields()[source]

Return a list of config fields

name = None
class djangofloor.conf.providers.ConfigProvider[source]

Base class of config provider.

get_extra_settings()[source]

Return all settings internally defined.

Returns:an iterable of (setting_name, value)
get_value(config_field)[source]

Get the internal value if the config field is present in its internal values. Otherwise returns the current value of the config field.

has_value(config_field)[source]

Return True if a config_field is present in the file

is_valid()[source]

Return True if the provider is valid (for example, the corresponding file is missing).

name = None
set_value(config_field, include_doc=False)[source]

Get the value of the config_field and set its internal value

to_str()[source]

Convert all its internal values to a string

class djangofloor.conf.providers.DictProvider(values)[source]

Use a plain Python dict as a setting provider

get_extra_settings()[source]

Return all uppercase keys of the internal dict as valid filenames

get_value(config_field)[source]

get a value from the internal dict if present

has_value(config_field)[source]

check if the value is present in the internal dict

is_valid()[source]

always True

name = 'dict'
set_value(config_field, include_doc=False)[source]

modify the internal dict for storing the value

to_str()[source]

display the internal dict

class djangofloor.conf.providers.IniConfigProvider(config_file=None)[source]

Read a config file using the .ini syntax.

get_extra_settings()[source]

No extra setting can be defined in a config file

get_value(config_field: djangofloor.conf.fields.ConfigField)[source]

get option from the config file

has_value(config_field: djangofloor.conf.fields.ConfigField)[source]

return True if the option is defined in the config file

is_valid()[source]

Return True if the config file exists

name = '.ini file'
set_value(config_field: djangofloor.conf.fields.ConfigField, include_doc: bool = False)[source]

update the internal config file

to_str()[source]

Display the config file

class djangofloor.conf.providers.PythonConfigFieldsProvider(value=None)[source]

Provide a list of djangofloor.conf.fields.ConfigField from an attribute in a Python module.

get_config_fields()[source]

Return the list that is defined in the module by the attribute name

name = 'Python attribute'
class djangofloor.conf.providers.PythonFileProvider(module_filename)[source]

Load a Python module from the filename

name = 'Python file'
class djangofloor.conf.providers.PythonModuleProvider(module_name=None)[source]

Load a Python module from its dotted name

get_extra_settings()[source]

Return all values that look like a Django setting (i.e. uppercase variables)

get_value(config_field)[source]

Get the value of a variable defined in the Python module.

has_value(config_field)[source]

True if the corresponding variable is defined in the module

is_valid()[source]

Return True if the module can be imported

name = 'Python module'
set_value(config_field, include_doc=False)[source]

Set the value of the config field in an internal dict

to_str()[source]

Display values as if set in a Python module