Sunday, May 16, 2021

The file__thumbnail in FileUsage.detail_layout doesn’t seem to work. Why?

Sharif submitted a solution, and this solution didn’t cause any test cases to break. But it would have caused a problem with a remote field to a virtual ForeignKey. I was afraid that there are uncovered cases where his change would break things. So I started to dig into it: Using remote virtual fields in a detail view. Result: yes, we do have remote fields to virtual ForeignKey fields, but until now we did never use them in any detail window. And the issue occurred only there. I verified also for Lino Welfare (added a list of all remote virtual fields in The Lino Welfare “Eupen” variant)

Minor internal changes:

lino.core.store.StoreField.value2dict() now takes the field name as an argument. The reason for this is a hack in lino.core.store.create_atomizer() where we create a StoreField instance based on the leaf field and then patch some methods of it. A StoreField actually doesn’t know its name. (TODO: shouldn’t we remove the StoreField.name attribute altogether?)

I wrote a new utility function lino.api.doctest.walk_store_fields().

I thought “Oops, the actors users.My, ledger.ItemsByVoucher, ledger.ByJournal, ledger.PrintableByJournal and sheets.EntriesByReport were not declared as abstract”.

But that was a pitfall. They don’t need to be explicitly declared abstract because Lino knows it: They are subclasses of DbTable having their model at None. I had forgotten the Actor.is_abstract() method. The problem was that lino.api.doctest.walk_store_fields() filtered on Actor.abstract instead of calling Actor.is_abstract(). lino.utils.diag.Analyzer.get_complexity_factors() now uses Actor.is_abstract()