class documentation

class ConfigDict(dict):

View In Hierarchy

A dict-like configuration storage with additional support for namespaces, validators, meta-data, on_change listeners and more.

This storage is optimized for fast read access. Retrieving a key or using non-altering dict methods (e.g. dict.get()) has no overhead compared to a native dict.

Method load​_config Load values from an *.ini style config file.
Method load​_dict Import values from a dictionary structure. Nesting can be used to represent namespaces.
Method meta​_get Return the value of a meta field for a key.
Method meta​_list Return an iterable of meta field names defined for a key.
Method meta​_set Set the meta field for a key to a new value. This triggers the on-change handler for existing keys.
Method update If the first parameter is a string, all keys are prefixed with this namespace. Apart from that it works just as the usual dict.update(). Example: update('some.namespace', key='value')
Class ​Namespace Undocumented
Method __call__ Undocumented
Method __delattr__ Undocumented
Method __delitem__ Undocumented
Method __getattr__ Undocumented
Method __init__ Undocumented
Method __setattr__ Undocumented
Method __setitem__ Undocumented
Method clear Undocumented
Method setdefault Undocumented
Class Variable __slots__ Undocumented
Instance Variable ​_meta Undocumented
Instance Variable ​_on​_change Undocumented
def load_config(self, filename):

Load values from an *.ini style config file.

If the config file contains sections, their names are used as namespaces for the values within. The two special sections DEFAULT and bottle refer to the root namespace (no prefix).

def load_dict(self, source, namespace='', make_namespaces=False):

Import values from a dictionary structure. Nesting can be used to represent namespaces.

>>> ConfigDict().load_dict({'name': {'space': {'key': 'value'}}})
{'name.space.key': 'value'}
def meta_get(self, key, metafield, default=None):
Return the value of a meta field for a key.
def meta_list(self, key):
Return an iterable of meta field names defined for a key.
def meta_set(self, key, metafield, value):
Set the meta field for a key to a new value. This triggers the on-change handler for existing keys.
def update(self, *a, **ka):
If the first parameter is a string, all keys are prefixed with this namespace. Apart from that it works just as the usual dict.update(). Example: update('some.namespace', key='value')
def __call__(self, *a, **ka):

Undocumented

def __delattr__(self, key):

Undocumented

def __delitem__(self, key):

Undocumented

def __getattr__(self, key):

Undocumented

def __init__(self, *a, **ka):

Undocumented

def __setattr__(self, key, value):

Undocumented

def __setitem__(self, key, value):

Undocumented

def clear(self):

Undocumented

def setdefault(self, key, value):

Undocumented

__slots__: tuple[str, ...] =

Undocumented

_meta: dict =

Undocumented

_on_change =

Undocumented