Skip to main content

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​

AttributeTypeDescription
callbackcallable = nullA 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​

NameTypeDescription
confdictThe initial configuration data to be stored.
callbackcallableA 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​

NameTypeDescription
*argsanyPositional arguments containing mappings or iterables of key-value pairs.
**kwargsanyKeyword 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​

NameTypeDescription
*argsanyArguments passed to the underlying dictionary's setdefault method, typically a key and an optional default value.
**kwargsanyKeyword arguments passed to the underlying dictionary's setdefault method.

Returns​

TypeDescription
anyThe 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​

TypeDescription
objectThe finalized configuration settings object returned by the callback function.