magpie.ui.login¶
Submodules¶
Attributes¶
Classes¶
Handles UI operations related to login to, logout from, or registration of user accounts. |
Functions¶
|
Search in order for matched value of |
|
Immediately sets the logger level to avoid duplicate log outputs from the root logger and this logger when |
|
Package Contents¶
- magpie.ui.login.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
: search in
MAGPIE_CONSTANTS
search in settings if specified
search alternative setting names (see below)
search in
magpie.constants
definitionssearch in environment variables
Parameter
constant_name
is 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_name
is provided as alternative name, it is used as is to search for results ifconstant_name
was not found. Otherwise,magpie.[variable_name]
is used for additional search when the formatMAGPIE_[VARIABLE_NAME]
was used forconstant_name
(i.e.:MAGPIE_ADMIN_USER
will also search formagpie.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 areNone
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)
- Search in order for matched value of
- class magpie.ui.login.LoginViews(request)[source]¶
Bases:
magpie.ui.utils.AdminRequests
,magpie.ui.utils.BaseViews
Handles UI operations related to login to, logout from, or registration of user accounts.
Warning
Admin requests are applicable only when using the temporary login. The temporary session is handled by dispatching operations to
AdminRequest
. Only those methods should work with elevated session to ensure that returning those views in this class are back to unauthenticated level access.- register_user()[source]¶
User self-registration form results.
Note
The template employed for this form is reused for user creation by an administrator as the fields and validation of inputs are essentially the same. Their actual processing is different though, as in this case, the user attempting registration is not yet logged nor has any administrative access.
- magpie.ui.login.get_logger(name: magpie.typedefs.Str, level: int | None = None, force_stdout: bool = None, message_format: magpie.typedefs.Str | None = None, datetime_format: magpie.typedefs.Str | None = None) logging.Logger [source]¶
Immediately sets the logger level to avoid duplicate log outputs from the root logger and this logger when level is
logging.NOTSET
.