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).

Attributes

MAGPIE_MODULE_DIR

MAGPIE_ROOT

MAGPIE_CONFIG_DIR

MAGPIE_PROVIDERS_CONFIG_PATH

MAGPIE_PROVIDERS_HOOKS_PATH

MAGPIE_PERMISSIONS_CONFIG_PATH

MAGPIE_WEBHOOKS_CONFIG_PATH

MAGPIE_CONFIG_PATH

MAGPIE_INI_FILE_PATH

MAGPIE_ENV_DIR

MAGPIE_ENV_FILE

MAGPIE_POSTGRES_ENV_FILE

_MAGPIE_ENV_EXAMPLE

_POSTGRES_ENV_EXAMPLE

MAGPIE_URL

MAGPIE_SECRET

MAGPIE_COOKIE_NAME

MAGPIE_COOKIE_EXPIRE

MAGPIE_PASSWORD_MIN_LENGTH

MAGPIE_ADMIN_USER

MAGPIE_ADMIN_PASSWORD

MAGPIE_ADMIN_EMAIL

MAGPIE_ADMIN_GROUP

MAGPIE_ANONYMOUS_USER

MAGPIE_ANONYMOUS_PASSWORD

MAGPIE_ANONYMOUS_EMAIL

MAGPIE_ANONYMOUS_GROUP

MAGPIE_EDITOR_GROUP

MAGPIE_USERS_GROUP

MAGPIE_CRON_LOG

MAGPIE_DB_MIGRATION

MAGPIE_DB_MIGRATION_ATTEMPTS

MAGPIE_LOG_LEVEL

MAGPIE_LOG_PRINT

MAGPIE_LOG_REQUEST

MAGPIE_LOG_EXCEPTION

MAGPIE_UI_ENABLED

MAGPIE_UI_THEME

PHOENIX_USER

PHOENIX_PASSWORD

PHOENIX_HOST

PHOENIX_PORT

PHOENIX_PUSH

TWITCHER_PROTECTED_PATH

TWITCHER_PROTECTED_URL

TWITCHER_HOST

GITHUB_CLIENT_ID

GITHUB_CLIENT_SECRET

WSO2_HOSTNAME

WSO2_CLIENT_ID

WSO2_CLIENT_SECRET

WSO2_CERTIFICATE_FILE

WSO2_SSL_VERIFY

MAGPIE_POSTGRES_USERNAME

MAGPIE_POSTGRES_PASSWORD

MAGPIE_POSTGRES_HOST

MAGPIE_POSTGRES_PORT

MAGPIE_POSTGRES_DB

MAGPIE_ADMIN_PERMISSION

MAGPIE_LOGGED_PERMISSION

MAGPIE_CONTEXT_PERMISSION

MAGPIE_LOGGED_USER

MAGPIE_DEFAULT_PROVIDER

MAGPIE_USER_NAME_MAX_LENGTH

MAGPIE_GROUP_NAME_MAX_LENGTH

MAGPIE_CONSTANTS

_REGEX_ASCII_ONLY

Functions

_get_default_log_level(→ magpie.typedefs.Str)

Get logging level from INI configuration file or fallback to default INFO if it cannot be retrieved.

get_constant_setting_name(→ magpie.typedefs.Str)

Find the equivalent setting name of the provided environment variable name.

get_constant(→ magpie.typedefs.SettingValue)

Search in order for matched value of constant_name:

Module Contents

magpie.constants.MAGPIE_MODULE_DIR[source]
magpie.constants.MAGPIE_ROOT[source]
magpie.constants.MAGPIE_CONFIG_DIR[source]
magpie.constants.MAGPIE_PROVIDERS_CONFIG_PATH[source]
magpie.constants.MAGPIE_PROVIDERS_HOOKS_PATH[source]
magpie.constants.MAGPIE_PERMISSIONS_CONFIG_PATH[source]
magpie.constants.MAGPIE_WEBHOOKS_CONFIG_PATH[source]
magpie.constants.MAGPIE_CONFIG_PATH[source]
magpie.constants.MAGPIE_INI_FILE_PATH[source]
magpie.constants.MAGPIE_ENV_DIR[source]
magpie.constants.MAGPIE_ENV_FILE[source]
magpie.constants.MAGPIE_POSTGRES_ENV_FILE[source]
magpie.constants._MAGPIE_ENV_EXAMPLE[source]
magpie.constants._POSTGRES_ENV_EXAMPLE[source]
magpie.constants._get_default_log_level() magpie.typedefs.Str[source]

Get logging level from INI configuration file or fallback to default INFO if it cannot be retrieved.

magpie.constants.MAGPIE_URL[source]
magpie.constants.MAGPIE_SECRET[source]
magpie.constants.MAGPIE_PASSWORD_MIN_LENGTH[source]
magpie.constants.MAGPIE_ADMIN_USER[source]
magpie.constants.MAGPIE_ADMIN_PASSWORD[source]
magpie.constants.MAGPIE_ADMIN_EMAIL[source]
magpie.constants.MAGPIE_ADMIN_GROUP[source]
magpie.constants.MAGPIE_ANONYMOUS_USER[source]
magpie.constants.MAGPIE_ANONYMOUS_PASSWORD[source]
magpie.constants.MAGPIE_ANONYMOUS_EMAIL[source]
magpie.constants.MAGPIE_ANONYMOUS_GROUP[source]
magpie.constants.MAGPIE_EDITOR_GROUP[source]
magpie.constants.MAGPIE_USERS_GROUP[source]
magpie.constants.MAGPIE_CRON_LOG[source]
magpie.constants.MAGPIE_DB_MIGRATION[source]
magpie.constants.MAGPIE_DB_MIGRATION_ATTEMPTS[source]
magpie.constants.MAGPIE_LOG_LEVEL[source]
magpie.constants.MAGPIE_LOG_PRINT[source]
magpie.constants.MAGPIE_LOG_REQUEST[source]
magpie.constants.MAGPIE_LOG_EXCEPTION[source]
magpie.constants.MAGPIE_UI_ENABLED[source]
magpie.constants.MAGPIE_UI_THEME[source]
magpie.constants.PHOENIX_USER[source]
magpie.constants.PHOENIX_PASSWORD[source]
magpie.constants.PHOENIX_HOST[source]
magpie.constants.PHOENIX_PORT[source]
magpie.constants.PHOENIX_PUSH[source]
magpie.constants.TWITCHER_PROTECTED_PATH[source]
magpie.constants.TWITCHER_PROTECTED_URL[source]
magpie.constants.TWITCHER_HOST[source]
magpie.constants.GITHUB_CLIENT_ID[source]
magpie.constants.GITHUB_CLIENT_SECRET[source]
magpie.constants.WSO2_HOSTNAME[source]
magpie.constants.WSO2_CLIENT_ID[source]
magpie.constants.WSO2_CLIENT_SECRET[source]
magpie.constants.WSO2_CERTIFICATE_FILE[source]
magpie.constants.WSO2_SSL_VERIFY[source]
magpie.constants.MAGPIE_POSTGRES_USERNAME[source]
magpie.constants.MAGPIE_POSTGRES_PASSWORD[source]
magpie.constants.MAGPIE_POSTGRES_HOST[source]
magpie.constants.MAGPIE_POSTGRES_PORT[source]
magpie.constants.MAGPIE_POSTGRES_DB[source]
magpie.constants.MAGPIE_ADMIN_PERMISSION = 'admin'[source]
magpie.constants.MAGPIE_LOGGED_PERMISSION = 'MAGPIE_LOGGED_USER'[source]
magpie.constants.MAGPIE_CONTEXT_PERMISSION = 'MAGPIE_CONTEXT_USER'[source]
magpie.constants.MAGPIE_LOGGED_USER = 'current'[source]
magpie.constants.MAGPIE_DEFAULT_PROVIDER = 'ziggurat'[source]
magpie.constants.MAGPIE_USER_NAME_MAX_LENGTH = 64[source]
magpie.constants.MAGPIE_GROUP_NAME_MAX_LENGTH = 64[source]
magpie.constants.MAGPIE_CONSTANTS = ['MAGPIE_CONSTANTS', 'MAGPIE_ADMIN_PERMISSION', 'MAGPIE_LOGGED_PERMISSION',...[source]
magpie.constants._REGEX_ASCII_ONLY[source]
magpie.constants.get_constant_setting_name(name: magpie.typedefs.Str) magpie.typedefs.Str[source]

Find the equivalent setting name of the provided environment variable name.

Lower-case name and replace all non-ascii chars by _. Then, convert known prefixes with their dotted name.

magpie.constants.get_constant(constant_name: magpie.typedefs.Str, settings_container: magpie.typedefs.AnySettingsContainer | None = None, settings_name: magpie.typedefs.Str | None = None, default_value: magpie.typedefs.SettingValue | None = None, raise_not_set: bool = True, raise_missing: bool = True, print_missing: bool = False, empty_missing: bool = False) magpie.typedefs.SettingValue[source]
Search in order for matched value of constant_name:
  1. search in MAGPIE_CONSTANTS

  2. search in settings if specified

  3. search alternative setting names (see below)

  4. search in magpie.constants definitions

  5. search in environment variables

Parameter constant_name is expected to have the format MAGPIE_[VARIABLE_NAME] although any value can be passed to retrieve generic settings from all above-mentioned search locations.

If settings_name is provided as alternative name, it is used as is to search for results if constant_name was not found. Otherwise, magpie.[variable_name] is used for additional search when the format MAGPIE_[VARIABLE_NAME] was used for constant_name (i.e.: MAGPIE_ADMIN_USER will also search for magpie.admin_user and so on for corresponding constants).

Parameters:
  • constant_name – key to search for a value

  • settings_container – WSGI application settings container (if not provided, uses found one in current thread)

  • 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_not_set – raise an exception if the found key is None, search until last case if others are None

  • raise_missing – raise exception if key is not found anywhere

  • print_missing – print message if key is not found anywhere, return None

  • empty_missing – consider an empty value for an existing key as if it was missing (i.e.: as if not set).

Returns:

found value or default_value

Raises:
  • ValueError – if resulting value is invalid based on options (by default raise missing/empty/None value)

  • LookupError – if no appropriate value could be found from all search locations (according to options)