pluserable.data.sqlalchemy.repository module

Use the SQLAlchemy session to retrieve and store models.

class pluserable.data.sqlalchemy.repository.Repository(kerno, session_factory=None)[source]

Bases: pluserable.data.repository.AbstractRepo, Generic[pluserable.data.typing.TActivation, pluserable.data.typing.TGroup]

A repository that uses SQLAlchemy for storage.

Activation
Group
User
delete_activation(user, activation)[source]

Delete the Activation instance from the database.

Return type

None

delete_expired_activations(now=None)[source]

Delete all old activations.

Return type

int

get_activation_by_code(code)[source]

Return the Activation with code, or None.

Return type

Optional[TypeVar(TActivation)]

get_or_create_user_by_email(email, details)[source]

Return User if email exists, else create User with details.

The returned User instance has a transient is_new flag. If the user is new, they need to go through password recovery. # TODO No access to tmp_password, create activation, send email

Return type

TUser

get_user_by_activation(activation)[source]

Return the user with activation, or None.

Return type

Optional[TUser]

get_user_by_email(email)[source]

Return a user with email, or None.

Return type

Optional[TUser]

get_user_by_id(id)[source]

Return the user with id, or None.

Return type

Optional[TUser]

get_user_by_username(username)[source]

Return a user with username, or None. Case-insensitive.

Return type

Optional[TUser]

one_user_by_email(email)[source]

Return a user with email, or raise.

Return type

TUser

q_activations()[source]

Return an iterator on all activations.

Return type

Query[TypeVar(TActivation)]

q_groups()[source]

Return an iterator on all groups.

Return type

Query[TypeVar(TGroup)]

q_users()[source]

Return a query for all users.

Return type

Query[TUser]