Data Structures

cfitall manages data stored in dictionaries.

The ConfigurationRegistry contains an internal values dictionary, where it holds configuration data for default values and developer-overridden values. Likewise, providers are expected to provide a dictionary of values to the registry via their dict property.

When a configuration value is requested, the dictionaries are merged together in a deterministic order, each overriding the last:

  • First, the defaults from the registry’s values dictionary are considered

  • Then each provider’s dict attribute, in the order listed in the manager's ordering attribute

  • Finally super values from the registry’s values dictionary

The merged configuration dictionary can be accessed directly via the registry’s dict property; individual values can also be retrieved by passing the registry’s get() method (or one of its typed variants) a valid configuration key.

Dotted Paths / Configuration Keys

For convenience, dictionary keys are “flattened” into a dotted path notation, also referred to as a configuration key, in a number of contexts throughout the library:

from cfitall.registry import ConfigurationRegistry
cf = ConfigurationRegistry("app")

# services.database.port is a configuration key / dotted path notation
cf.set_default("services.database.port", 5432)

# the configuration key is a concatenation of dictionary keys
assert cf.get("services.database.port") == cf.dict["services"]["database"]["port"]

You can view a list of configuration keys (that the registry is aware of) by inspecting the registry’s config_keys property.