PendingConfiguration
This class acts as a temporary container for application settings before they are explicitly finalized. It allows configuration values to be set or updated directly while deferring the creation of a concrete settings object until a key is accessed. Once a value is requested, the class triggers a callback to finalize and replace the configuration.
Attributes
| Attribute | Type | Description |
|---|---|---|
| callback | callable = null | A callable used to finalize the configuration and return a concrete settings object when the data is first accessed. |
Constructor
Signature
def PendingConfiguration(
conf: dict,
callback: callable
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| conf | dict | The initial configuration data to be stored. |
| callback | callable | A function to be called when the configuration needs to be finalized. |
Methods
clear()
@classmethod
def clear()
Removes all currently stored configuration items from the pending data dictionary.
update()
@classmethod
def update(
*args: any,
**kwargs: any
)
Updates the pending configuration with multiple key-value pairs from another mapping or iterable.
Parameters
| Name | Type | Description |
|---|---|---|
| *args | any | Positional arguments containing mappings or iterables of key-value pairs. |
| **kwargs | any | Keyword arguments representing configuration keys and their values. |
setdefault()
@classmethod
def setdefault(
*args: any,
**kwargs: any
) - > any
Returns the value of a key if it exists; otherwise, inserts the key with a specified default value.
Parameters
| Name | Type | Description |
|---|---|---|
| *args | any | Arguments passed to the underlying dictionary's setdefault method, typically a key and an optional default value. |
| **kwargs | any | Keyword arguments passed to the underlying dictionary's setdefault method. |
Returns
| Type | Description |
|---|---|
any | The existing value for the key or the newly set default value. |
data()
@classmethod
def data() - > object
Triggers the finalization callback to convert pending settings into a concrete configuration object and caches the result.
Returns
| Type | Description |
|---|---|
object | The finalized configuration settings object returned by the callback function. |