diff --git a/src/moin/config/default.py b/src/moin/config/default.py index 1c469c5a8..0013fe023 100644 --- a/src/moin/config/default.py +++ b/src/moin/config/default.py @@ -266,6 +266,15 @@ def __getitem__(self, item): """Make it possible to access a config object like a dict""" return getattr(self, item) + def get(self, item, default=None): + """Dict-like get method. + Return the value for key if key is in the dictionary, else default. + If default is not given, it defaults to None, so that this method never raises a KeyError.""" + try: + return getattr(self, item) + except AttributeError: + return default + class DefaultConfig(ConfigFunctionality): """Configuration base class with default config values