Welcome | Get started | Dive | Contribute | Topics | Reference | Changes | More
lino.core.actors
¶
This module defines the Actor
class.
- class lino.core.actors.Actor¶
The base class for all actors (data tables). Subclassed by
AbstractTable
,Table
,ChoiceList
andFrame
.- model¶
The model on which this table iterates.
The application developer can specify either the model class itself or a string of type
'app.Model'
.If this is not None, it should be a subclass of
lino.core.fields.TableRow
.
- 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.
Application code usually doesn’t need to specify this because it is automatically set on actors whose
master_key
is specified.Setting this to something else than None will turn the table into a slave table.
If the
master
is something else than a database model (e.g. a ChoiceList), then the actor must also define aget_master_instance()
method.
- master_key¶
The name of a field that points to its
master
.The field named by
master_key
should usually be aForeignKey
field.Special cases:
lino_xl.lib.cal.EntriesByGuest
shows the entries having a presence pointing to this guest.The
master_key
is automatically added tohidden_columns
.
- 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
andlino_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 ofadmin_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 notreadonly
.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.
When this is not None, you must also implement a custom version of
get_row_by_pk()
that returns the same database row regardless the given primary key.This 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 ofdefault_record_id = 'row'
.
- 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.