magpie.cli.register_defaults

Magpie helpers for user and group registration.

Module Contents

Functions

register_user_with_group(→ None)

Registers the user if missing and associate him to a group specified by name, also created if missing.

init_anonymous(→ None)

Registers into the database the user and group matching configuration values of.

init_admin(→ None)

Registers into the database the user and group matching configuration values of.

init_users_group(→ None)

Registers into database the group matching magpie.constants.MAGPIE_USERS_GROUP if not defined.

register_defaults(→ None)

Registers into database every undefined default users and groups matching following variables:

make_parser(→ argparse.ArgumentParser)

main(→ Any)

Attributes

LOGGER

magpie.cli.register_defaults.LOGGER[source]
magpie.cli.register_defaults.register_user_with_group(user_name: magpie.typedefs.Str, group_name: magpie.typedefs.Str, email: magpie.typedefs.Str, password: magpie.typedefs.Str | None, db_session: sqlalchemy.orm.session.Session) None[source]

Registers the user if missing and associate him to a group specified by name, also created if missing.

Parameters:
  • user_name – name of the user to create (if missing) and to make part of the group (if specified)

  • group_name – name of the group to create (if missing and specified) and to make the user join (if not already)

  • email – email of the user to be created (if missing)

  • password – password of the user to be created (if missing), auto-generate if not provided (None).

  • db_session – database connexion to apply changes

Warning

Should be employed only for special users/groups in this module as other expected API behaviour and operations will not be applied (ex: create additional permissions or user-group references).

magpie.cli.register_defaults.init_anonymous(db_session: sqlalchemy.orm.session.Session, settings: magpie.typedefs.AnySettingsContainer | None = None) None[source]

Registers into the database the user and group matching configuration values of.

magpie.constants.MAGPIE_ANONYMOUS_USER and magpie.constants.MAGPIE_ANONYMOUS_GROUP respectively if not defined.

Afterwards, updates the group’s parameters to ensure integrity with Magpie settings.

magpie.cli.register_defaults.init_admin(db_session: sqlalchemy.orm.session.Session, settings: magpie.typedefs.AnySettingsContainer | None = None) None[source]

Registers into the database the user and group matching configuration values of.

magpie.constants.MAGPIE_ADMIN_USER and magpie.constants.MAGPIE_ADMIN_GROUP respectively if not defined.

Also associates the created admin user with the admin group and give it admin permissions. Finally, updates the group’s parameters to ensure integrity with Magpie settings.

magpie.cli.register_defaults.init_users_group(db_session: sqlalchemy.orm.session.Session, settings: magpie.typedefs.AnySettingsContainer | None = None) None[source]

Registers into database the group matching magpie.constants.MAGPIE_USERS_GROUP if not defined.

magpie.cli.register_defaults.register_defaults(db_session: sqlalchemy.orm.session.Session | None = None, settings: magpie.typedefs.AnySettingsContainer | None = None, ini_file_path: magpie.typedefs.Str | None = None) None[source]

Registers into database every undefined default users and groups matching following variables:

magpie.cli.register_defaults.make_parser() argparse.ArgumentParser[source]
magpie.cli.register_defaults.main(args: Sequence[magpie.typedefs.Str] | None = None, parser: argparse.ArgumentParser | None = None, namespace: argparse.Namespace | None = None) Any[source]