A data view is called a slave table when it "depends" on a master.
For example the BooksByAuthor table in Introduction to data views shows the books written by a given author.
A slave table cannot render if we don't define the master. You cannot
ask Lino to render the
BooksByAuthor table if you don't
specify for which author you want it.
Special types of masters¶
Slave tables are most often used as elements of a detail layout. In this case Lino renders them in a slave panel widget, and the current record is the master.
But the master can be something else than a database row. For example
lino_xl.lib.ledger.MovementsByMatchthe master is a
lino_welfare.modlib.debts.PrintEntriesByBudgetthe master is an
If the master instance is not a subclass of
it must be JSON serializable.
Slave tables with remote master¶
master_key of a slave table can be a remote
When you have three models A, B and C with A.b being a pointer to B and B.c being a pointer to C, then you can design a table CsByA which shows the C instances of a given A instance by saying:
class CsByA(Cs): master_key = "c__b"
lino_xl.lib.courses.ActivitiesByTopic shows all activities
about a given topic. But an activity has no foreign key
you cannot say
master_key = 'topic'. But a course does know its topic
indirectly because it knows its activity line, and the activity line
knows its topic. So you can specify a remote field:
class ActivitiesByTopic(Courses): master_key = 'line__topic' allow_create = False
A slave table with a remote master should have
allow_create set to False because we cannot set a
line for a new course.