cement.core.config
Cement core config module.
- class cement.core.config.ConfigHandler(**kw)[source]
Bases:
ConfigInterface
,Handler
Config handler implementation.
- abstract _parse_file(file_path)[source]
Parse a configuration file at
file_path
and store it. This function must be provided by the handler implementation (that is sub-classing this).
- parse_file(file_path)[source]
Ensure we are using the absolute/expanded path to
file_path
, and then callself._parse_file
to parse config file settings from it, overwriting existing config settings.Developers sub-classing from here should generally override
_parse_file
which handles just the parsing of the file and leaving this function to wrap any checks/logging/etc.
- class cement.core.config.ConfigInterface(**kw)[source]
Bases:
Interface
This class defines the Config Interface. Handlers that implement this interface must provide the methods and attributes defined below. In general, most implementations should sub-class from the provided
ConfigHandler
base class as a starting point.- class Meta[source]
Bases:
object
Handler meta-data.
- interface = 'config'
The string identifier of the interface.
- abstract add_section(section)[source]
Add a new section if it doesn’t already exist.
- Parameters:
section – The section label to create.
- Returns:
None
- abstract get(section, key)[source]
Return a configuration value based on
section.key
. Must honor environment variables if they exist to override the config… for exampleconfig['myapp']['foo']['bar']
must be overridable by the environment variableMYAPP_FOO_BAR
…. Note thatMYAPP_
must prefix all vars, thereforeconfig['redis']['foo']
would be overridable byMYAPP_REDIS_FOO
… butconfig['myapp']['foo']['bar']
would not have a double prefix ofMYAPP_MYAPP_FOO_BAR
.
- abstract get_dict()[source]
Return a dict of the entire configuration.
- Returns:
A dictionary of the entire config.
- Return type:
- abstract get_sections()[source]
Return a list of configuration sections.
- Returns:
A list of config sections.
- Return type: