ConfigurationView
A view over an applications configuration dictionaries.
Attributes
| Attribute | Type | Description |
|---|---|---|
| prefix | str | String prefix applied to keys during lookup to support namespace-specific configuration access. |
| _keys | List[str] | List of transformation functions or alternative keys used to resolve configuration values when the primary key is missing. |
Constructor
Signature
def ConfigurationView(
changes: Mapping,
defaults: Mapping = None,
keys: List[str] = None,
prefix: str = None
) - > None
Parameters
| Name | Type | Description |
|---|---|---|
| changes | Mapping | A mapping containing configuration changes. |
| defaults | Mapping = None | A list of dictionaries containing the default configuration values. |
| keys | List[str] = None | A list of keys to be used for configuration lookups. |
| prefix | str = None | An optional string prefix to be applied to configuration keys. |
Methods
first()
@classmethod
def first(
*keys: str
) - > Any
Returns the first non-null value found for a series of provided configuration keys.
Parameters
| Name | Type | Description |
|---|---|---|
| *keys | str | A variable number of configuration keys to check in order. |
Returns
| Type | Description |
|---|---|
Any | The first available value from the provided keys, or None if none are found. |
get()
@classmethod
def get(
key: str,
default: Any
) - > Any
Attempts to retrieve a configuration value, returning a default if the key is not found.
Parameters
| Name | Type | Description |
|---|---|---|
| key | str | The configuration key to search for. |
| default | Any | The fallback value to return if the key does not exist in any mapping. |
Returns
| Type | Description |
|---|---|
Any | The configuration value if found; otherwise, the provided default value. |
clear()
@classmethod
def clear() - > null
Remove all changes, but keep defaults.
Returns
| Type | Description |
|---|---|
null |
swap_with()
@classmethod
def swap_with(
other: [ConfigurationView](configurationview.md?sid=celery_utils_collections_configurationview)
) - > null
Replaces the current configuration state, including changes and defaults, with the state of another ConfigurationView.
Parameters
| Name | Type | Description |
|---|---|---|
| other | [ConfigurationView](configurationview.md?sid=celery_utils_collections_configurationview) | The other configuration view instance from which to copy the state. |
Returns
| Type | Description |
|---|---|
null |