magpie.constants¶
Constant settings for Magpie application.
Constants defined with format MAGPIE_[VARIABLE_NAME] can be matched with corresponding
settings formatted as magpie.[variable_name] in the magpie.ini configuration file.
Note
Since the magpie.ini file has to be loaded by the application to retrieve various configuration settings,
constant MAGPIE_INI_FILE_PATH (or any other path variable defined before it - see below) has to be defined
by environment variable if the default location is not desired (ie: if you want to provide your own configuration).
Module Contents¶
-
magpie.constants.get_constant_setting_name(name)[source]¶ Lower-case name and replace all non-ascii chars by _.
-
magpie.constants.get_constant(constant_name, settings_container=None, settings_name=None, default_value=None, raise_missing=True, print_missing=False, raise_not_set=True) → SettingValue[source]¶ - Search in order for matched value of
constant_name: - search in settings if specified
- search alternative setting names
- search in
magpie.constantsdefinitions - search in environment variables
Parameter
constant_nameis expected to have the formatMAGPIE_[VARIABLE_NAME]although any value can be passed to retrieve generic settings from all above mentioned search locations.If
settings_nameis provided as alternative name, it is used as is to search for results ifconstant_namewas not found. Otherwise,magpie.[variable_name]is used for additional search when the formatMAGPIE_[VARIABLE_NAME]was used forconstant_name(ie:MAGPIE_ADMIN_USERwill also search formagpie.admin_userand so on for corresponding constants).Parameters: - constant_name – key to search for a value
- settings_container – wsgi app settings container
- settings_name – alternative name for settings if specified
- default_value – default value to be returned if not found anywhere, and exception raises are disabled.
- raise_missing – raise exception if key is not found anywhere
- print_missing – print message if key is not found anywhere, return None
- raise_not_set – raise an exception if the found key is None, search until last case if previous are None
Returns: found value or default_value
Raises: according message based on options (by default raise missing/None value)
- Search in order for matched value of