A series of optimizations while working on Lino Prima¶
Thursday, October 31, 2024
During the last week I did the following changes, which I plan to push soon.
We have a new attribute lino.core.actors.Actor.row_template
, which is a
kind of a context-sensitive template for __str__()
.
An avalanche of changes started because a piece of code in
lino_react.react.views.ApiList.get()
said:
ar = action_request(app_label, actor, request, request.GET, True)
ar.renderer = settings.SITE.kernel.default_renderer
Some of the results:
The default value for
lino.core.requests.BaseRequest.renderer`is now determined a bit differently. Traditionally it is either :attr:`default_renderer
(when the action request was created from an incoming HTTP request) ortext_renderer
(e.g. during a doctest).The
rt.login
function is no longer implemented as a method oflino.core.site.Site
but as a stand-alone function inlino.core.utils
.The
rt.show
function has a wrapperrt.shows
, which returns the output as a string instead of printing it to stdout. In unit tests we had code like this:s = cal.GuestsByEvent.request(evt).to_rst()
This has been replaced by:
s = rt.shows(cal.GuestsByEvent, evt)
The signature of lino.core.actors.Actor.row_as_summary()
is a bit more
explicit. Before:
def row_as_summary(cls, ar, obj, **kwargs):
After:
def row_as_summary(cls, ar, obj, text=None, **kwargs):
The lino.core.actors.Actor.group_by
is back, but in a new form. If
specified, it must be a callable, and it currently only for the display
mode “list” and only in the React front end. It uses a utility class
lino.utils.html.Grouper
. First usage example is in Lino Prima:
class ChallengeRatingsByProject(ChallengeRatings):
...
group_by = [lambda obj: obj.challenge.project_section]
There are also a few subtle optimizations in React front end for Lino.