Welcome | Get started | Dive | Contribute | Topics | Reference | Changes | More

lino.core.actors.actor

This module defines the Actor class.

class lino.core.actors.actor.Actor

The base class for all actors (data tables). Subclassed by AbstractTable, Table, ChoiceList and Frame.

model

The database model on which this table iterates.

Default value is None. Otherwise this must be a subclass of TableRow. You can specify either the model class itself or a string of type 'app_name.Model'.

required_roles

The user roles required to see this actor. See Introduction to permissions.

master

The class of master instances for requests on this table. When this is not None the table is a slave table.

Application code usually doesn’t need to specify this because it is automatically set during startup on actors whose master_key is specified.

If the master is something else than a database model (e.g. a ChoiceList), then the actor must also define a get_master_instance() method.

master_key

The name of a field that points to its master.

The field named by master_key should usually be a ForeignKey field.

Special cases: lino_xl.lib.cal.EventsByGuest shows the entries having a presence pointing to this guest.

The master_key is automatically added to hidden_columns.

title

The text to appear e.g. as window title when the actor’s default action has been called. If this is not set, Lino will use the label as title.

label

The text to appear e.g. on a button that will call the default action of an actor. This attribute is not inherited to subclasses. If this is None (the default value), Lino will call get_actor_label().

ignore_required_states

Whether to ignore the required states of workflow actions.

Default value is False. Set this to True on a workflow if you want to disable workflow control based on the state of the object.

Note that you must set this to True before importing any library workflows because permission handlers are defined when a workflow is imported.

sort_index = 60

The sort_index to be used when this table is being used by a ShowSlaveTable.

icon_name = None

The lino.core.actions.action.Action.icon_name to be used for a lino.core.actions.common.ShowSlaveTable action on this actor. Default value is None.

detail_html_template

The template to be used for rendering a row of this actor as a detail html page. Default value is “bootstrap5/detail.html”.

list_html_template

The template to be used for rendering a collection of rows of this actor as a table html page. Default value is “bootstrap5/table.html”.

auto_apply_params

Whether the parameter values of the parameter panel should be applied automatically when some value has been changed. Default value is True.

enable_slave_params
Whether the parameter panel could be shown in a slave panel
Default value is `False`.
toolbar_location

Not yet implemented. Should be one of ‘top’ (default), ‘bottom’, ‘right’, ‘left’ Default value is “top”.

hide_top_toolbar
See :ref:`dev.actor_config.hide_top_toolbar`.
Default value is `False`.
hide_navigator

See How to remove the navigation buttons. Default value is False.

get_navinfo(cls, ar, obj)

Return navigation info for the given obj in the given ar.

The default implementation assumes that you navigate on the data_iterator.

lino_xl.lib.calview.DayNavigator overrides this.

get_actor_label(self)

Return the label of this actor.

get_title(self, ar)

Return the title of this actor for the given action request ar.

The default implementation calls get_title_base() and get_title_tags() and returns a string of type BASE [ (TAG, TAG…)].

Override this if your table’s title should mention for example filter conditions. See also Table.get_title.

button_text

The text to appear on buttons of a ShowSlaveTable action for this actor.

get_title_base(self, ar)

Return the base part of the title. This should be a translatable string. This is called by get_title() to construct the actual title.

It is also called by lino.core.dashboard.DashboardItem.render_request()

get_title_tags(self, ar)

Yield a list of translatable strings to be added to the base part of the title. This is called by get_title() to construct the actual title.

default_display_modes

Which display mode to use, depending on available width. See Setting the default display mode.

extra_display_modes

A set of additional display modes to make available when rendering this table. See Activating extra display modes.

known_values

A dict of fieldname -> value pairs that specify “known values”.

Requests will automatically be filtered to show only existing records with those values. This is like filter, but new instances created in this Table will automatically have these values set.

obvious_fields

A set of names of fields that are considered obvious field.

welcome_message_when_count

Set this to an integer (e.g. 0) to tell Lino to make a generic welcome message “You have X items in Y” when the number of rows in this table is greater than the given integer.

The following class methods are None in the default implementation. Subclass can define them.

classmethod get_handle_name(self, ar)

Most actors use the same UI handle for each request. But e.g. lino_welfare.modlib.debts.models.PrintEntriesByBudget and lino_xl.lib.events.EventsByType override this to implement dynamic columns depending on it’s master_instance.

classmethod get_welcome_messages(self, ar)

If a method of this name is defined on an actor, then it must be a class method that takes an ar as single argument and returns or yields a list of welcome messages (messages to be displayed in the welcome block of admin_main.html).

Note that this handler will be called independently of whether the user has permission to view the actor or not.

More methods.

classmethod get_toolbar_actions(cls, parent, user_type)

Return a list of actions for which a button should exist in the toolbar of the specified “parent” action.

classmethod get_button_actions(cls, parent)

Return a sorted list of actions that should be available as buttons in the specified parent (a window action).

This is used (1) by get_toolbar_actions() and (2) to reduce the list of disabled actions in disabled_fields to those which make sense. dbtables.make_disabled_fields

classmethod get_actions(cls)

Return a sorted list of all bound actions offered by this actor.

abstract

Set this to True to prevent Lino from generating useless JavaScript if this is just an abstract base class to be inherited by other actors.

Note that this class attribute is not inherited to subclasses.

editable

Whether a data window on this actor is editable.

The front end uses this information to generate optimized JS code for these actors.

When this is False, Lino won’t even call get_view_permission() for actions that are not readonly.

Set this explicitly to True or False to make the whole actor editable or not. Otherwise Lino will guess what you want during startup and set it to False if the actor is a Table and has a get_data_rows method (which usually means that it is a virtual table), otherwise to True.

This attribute is not inherited to subclasses.

default_record_id

Turn this table into a single-row table.

The value must currently be either None or 'row' (or 'myself'). TODO: Rename this to single_row and make it a simple boolean so that the application developer can say single_row = True instead of default_record_id = 'row'.

When this is set, you must also implement a custom version of get_row_by_pk(), which is expected to return the same database row regardless the given primary key.

When this is set, Lino does not call get_default_action() and instead sets default_action and detail_action to a modified version of lino.core.actions.common.ShowDetail.

handle_uploaded_files

Handler for uploaded files. Same remarks as for disabled_fields.

app_label

Specify this if you want to “override” an existing actor.

The default value is deduced from the module where the subclass is defined.

Note that this attribute is not inherited from base classes.

lino.core.dbtables.table_factory() also uses this.

get_row_by_pk(cls, ar, pk)

Return the data row identified by the given primary key.

classmethod collect_my_masters(cls)

Collect information about the actors who use this actor as a slave.

Return a dictionary mapping Layout objects to they database model.

Introduction and use case see How to find the models that are de facto commentable.