Reference

class canaille.backends.models.Model[source]

Bases: object

Model abstract class.

delete()[source]

Removes the current instance from the database.

classmethod fuzzy(query, attributes=None, **kwargs)[source]

Works like query() but attribute values loosely be matched.

classmethod get(identifier=None, **kwargs)[source]

Works like query() but return only one element or None if no item is matching.

property identifier

Returns a unique value that will be used to identify the model instance. This value will be used in URLs in canaille, so it should be unique and short.

classmethod query(**kwargs)[source]

Performs a query on the database and return a collection of instances. Parameters can be any valid attribute with the expected value:

>>> User.query(first_name="George")

If several arguments are passed, the methods only returns the model instances that return matches all the argument values:

>>> User.query(first_name="George", last_name="Abitbol")

If the argument value is a collection, the methods will return the models that matches any of the values:

>>> User.query(first_name=["George", "Jane"])
reload()[source]

Cancels the unsaved modifications.

>>> user = User.get(user_name="george")
>>> user.display_name
George
>>> user.display_name = "Jane"
>>> user.display_name
Jane
>>> user.reload()
>>> user.display_name
George
save()[source]

Validates the current modifications in the database.

update(**kwargs)[source]

Assign a whole dict to the current instance. This is useful to update models based on forms.

>>> user = User.get(user_name="george")
>>> user.first_name
George
>>> user.update({
...     first_name="Jane",
...     last_name="Calamity",
... })
>>> user.first_name
Jane
class canaille.core.models.Group[source]

Bases: object

User model, based on the SCIM Group schema

class canaille.core.models.User(*args, **kwargs)[source]

Bases: object

User model, based on the SCIM User schema

check_password(password: str) bool[source]

Checks if the password matches the user password in the database.

has_password() bool[source]

Checks wether a password has been set for the user.

property locked: bool

Wether the user account has been locked or has expired.

login()[source]

Opens a session for the user.

classmethod logout()[source]

Closes the user session.

set_password(password: str)[source]

Sets a password for the user.