Welcome | Get started | Dive into Lino | Contribute | Topics | Reference | More

lino.core.boundaction

Classes

BoundAction(actor, action)

An Action that is bound to an Actor.

class lino.core.boundaction.BoundAction(actor, action)

Bases: object

An Action that is bound to an Actor. If an Actor has subclasses, each subclass "inherits" its actions.

request_from(ar, *args, **kw)

Create a request of this action from parent request ar.

get_row_permission(ar, obj, state)

Checks whether this bound action has permission to run on the given database object.

This will check requirements specified on the actor, which by default checks those defined on the model, which in turn checks those defined on the action by calling get_bound_action_permission().

get_bound_action_permission(ar, obj=None, state=None)

Checks whether the bound action gives permission to run.

If this is a list action, obj is None. If this is a row action, then obj is the current row. Note that this method does not (again) call any custom permission handler defined on the model.

This is done in two steps: first we check the requirements specified in required_roles and required_states, then (if these pass) we check any custom permissions defined on the action via get_action_permission.

The order of these is important since a custom permission handler of an action with default required_roles can make database queries based on ar.get_user(), which would cause errors like Cannot assign "<lino.core.auth.utils.AnonymousUser object at 0x7f562512f210>": "Upload.user" must be a "User" instance when called by anonymous.

get_view_permission(user_type)

Return True if this bound action is visible for users of this user_type.