Welcome | Get started | Dive | Contribute | Topics | Reference | Changes | More
lino.core.roles¶
Defines built-in user roles. See Introduction to permissions.
Functions
|
Check whether the given value is a valid required_roles specification. |
|
|
|
Utility function to find out the reason of a TypeError "Cannot create a consistent method resolution order (MRO)". |
|
Return a set of roles to be used for a required_roles. |
Classes
The role used by anonymous guest sessions. |
|
A user who can export to xls and pdf. |
|
|
A user with some expertise and more options than a beginner. |
|
A user who has permission to explore the database content, e.g. for writing statistical reports. |
A user who can create other users and modify their permissions. |
|
A user who can configure site-wide functionality. |
|
|
Every authenticated user has this role. |
A user who has permission to act as another user. |
|
|
Base class for all user roles. |
- class lino.core.roles.UserRole¶
Bases:
object
Base class for all user roles. Even anonymous users have this role.
- satisfies_requirement(required_roles)¶
Return True if this user role satisfies the specified role requirement.
required_roles is the set of required roles (class objects). Every item is either a class object (subclass of
<UserRole>
) or a tuple thereof. This role (an instance) must satisfy every specified requirement.
- has_required_roles(required_roles)¶
Return True if this user role satisfies the specified role requirement.
required_roles is the set of required roles (class objects). Every item is either a class object (subclass of
<UserRole>
) or a tuple thereof. This role (an instance) must satisfy every specified requirement.
- classmethod get_user_profiles()¶
Yield a series of all user profiles on this site which satisfy this role.
- class lino.core.roles.Expert¶
Bases:
DataExporter
A user with some expertise and more options than a beginner.
- class lino.core.roles.SiteStaff¶
-
A user who can configure site-wide functionality.
Certain privileged actions require this role:
Merging duplicate database records (
MergeAction
)Editing printable templates (
EditTemplate
)
- class lino.core.roles.Explorer¶
Bases:
UserRole
A user who has permission to explore the database content, e.g. for writing statistical reports.
- class lino.core.roles.SiteAdmin¶
Bases:
SiteStaff
,Supervisor
,Explorer
A user who can create other users and modify their permissions.
- lino.core.roles.login_required(*args)¶
Return a set of roles to be used for a required_roles.
An API shortcut available in
lino.api.dd
.
- lino.core.roles.check_required_roles(required_roles, actor)¶
Check whether the given value is a valid required_roles specification.
it must be iterable
every element must be either a subclass of
UserRole
or an iterable thereof.if an element is an iterable, then it may not be empty. Only the top-level iterable may be empty.
- lino.core.roles.checkmro(*args)¶
Utility function to find out the reason of a TypeError “Cannot create a consistent method resolution order (MRO)”.
Usage: imagine you have some code like this:
from one import A from two import B from three import C
# A, B and C are subclasses of UserRole
- class MyUserRole(A, B, C):
pass
and Python tells you that it cannot create a consistent MRO.
So somewhere in those classes A, B and C is a “duplicate” ancestor. And you have no idea where it is.
In that case you comment out the definition of MyUserRole and say:
checkmro(A, B, C):