duck.settings.settings

Provides access to application settings.

Module Contents

Classes

Settings

A class for managing Duck settings.

Functions

get_combined_settings

Combines default and user settings into a single dictionary.

settings_to_dict

Converts a settings module to a dictionary.

Data

SETTINGS

SETTINGS_MODULE

API

duck.settings.settings.SETTINGS: duck.settings.settings.Settings

‘get_combined_settings(…)’

duck.settings.settings.SETTINGS_MODULE

‘get(…)’

class duck.settings.settings.Settings

Bases: dict

A class for managing Duck settings.

This class extends the built-in dict to store settings in a dictionary-like format. It also provides a custom representation of the settings for debugging and logging.

Notes:

  • These settings can be altered at runtime once imported but the SETTINGS should be imported and edited at top level before importing anything related to Duck.

    Example:

    from duck.settings import SETTINGS
    
    # Edit settings inplace .e.g.,
    SETTINGS['ENABLE_HTTPS'] = True
    
    from duck.app import App
    
    app = App()
    
    if __name__ == '__main__':
        app.run()
    

Initialization

Initialize self. See help(type(self)) for accurate signature.

__repr__()
reload()

Re-execute the settings module and update this dict in-place.

… admonition:: Notes

The settings module will be the latest one set in DUCK_SETTINGS_MODULE.

source

None

The source of settings e.g., web.settings.

duck.settings.settings.get_combined_settings() duck.settings.settings.Settings

Combines default and user settings into a single dictionary.

Reads the default settings from duck.etc.settings and attempts to read user settings from a settings module in the current directory.

Returns:

Settings object derived from a dictionary containing the settings.

Return type:

Settings

Raises:

SettingsError – If there’s an error loading user settings.

duck.settings.settings.settings_to_dict(settings_module: str) duck.settings.settings.Settings

Converts a settings module to a dictionary.

Parameters:

settings_module – The path to the settings module.

Returns:

Settings object derived from a dictionary containing the settings.

Return type:

Settings

Raises:

ImportError – If the settings module cannot be imported.