Monday, July 31, 2017

I have a reproducible variant of #352 in Lino Tera:

  • runserver in lino_book.projects.lydia

  • log in as robin

  • Select Activities ‣ Individual therapies

  • Double click on the first line “ÕUNAPUU Õie (166)”

  • Switch to “Enrolments” tab

  • Click the “Confirm” action in the table of enrolments

You get the following error message:

Bad Request

Exception: ParameterStore of LayoutHandle for lino.core.layouts.ParamsLayout on expects a list of 6 values but got 10: [u’’, u’’, u’’, u’’, u’’, u’’, u’’, u’’, u’’, u’’]

and the server log says:

AjaxExceptionResponse Exception: ParameterStore of LayoutHandle for lino.core.layouts.ParamsLayout on expects a list of 6 values but got 10: [u'', u'', u'', u'', u'', u'', u'', u'', u'', u'']

in request GET /api/courses/EnrolmentsByTherapy/58?_dc=1501471612563&pv=&pv=&pv=&pv=&pv=&pv=&pv=&pv=&pv=&pv=&an=wf1&sr=58
  File "/site-packages/django/core/handlers/", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/site-packages/django/views/generic/", line 68, in view
    return self.dispatch(request, *args, **kwargs)
  File "/py27/local/lib/python2.7/site-packages/django/views/generic/", line 88, in dispatch
    return handler(request, *args, **kwargs)
  File "/lino/lino/modlib/extjs/", line 465, in get
    ar = ba.request(request=request, selected_pks=[pk])
  File "/lino/lino/core/", line 78, in request
    return*args, **kw)
  File "/lino/lino/core/", line 350, in request
    return TableRequest(**kw)
  File "/lino/lino/core/", line 1109, in __init__
    BaseRequest.__init__(self, **kw)
  File "/lino/lino/core/", line 211, in __init__
  File "/lino/lino/core/", line 350, in setup
    ActionRequest.setup(self, **kw)
  File "/lino/lino/core/", line 1167, in setup
  File "/lino/lino/core/", line 928, in parse_params
    self, len(self.param_fields), len(pv), pv))

[31/Jul/2017 03:26:52] "GET /api/courses/EnrolmentsByTherapy/58?_dc=1501471612563&pv=&pv=&pv=&pv=&pv=&pv=&pv=&pv=&pv=&pv=&an=wf1&sr=58 HTTP/1.1" 400 208

The problem was a tough one.

We do not want Lino.run_row_action to add the parameter values of its requesting panel when it is being run from within a “non-main context”. A “non-main context” is currently only in lino.core.actors.Actor.slave_as_html_meth() (i.e. when slave_grid_format is html. We now have a new attribute lino.core.requests.BaseRequest.is_on_main_actor per request.

Note that currently we also don’t pass the mk and mt paramneters (master key and master type). I think that this is correct.

But all this is to be observed.

Later I tried whether this fixes #1989. But it didn’t. I continued to search.

Side effects:

  • I saw that lino.core.utils.InstanceAction.request_from() still used the deprecated lino.core.requests.BaseRequest.setup_from() method. I converted it.

  • I saw that actually we must explicitly specify is_on_main_actor=False on most application code below get_slave_summary(). Hm… not very nice…

But still no fix for #1989 Here is the sequence to reproduce it:

  • runserver in lino_book.projects.adg

  • Log in as robin

  • Contacts –> Clients

  • Double click on the first client, click on the “Trends” tab.

  • In the Responses panel, under “Political compass” click on the green plus to create a new response

  • Confirm the insert window unchanged. Lino creates a Response object with default answers and displays it.

  • Click some answer in the first question (“1) If economic globalisation is inevitable, …”.

Note that the error comes only immediately after insert. The only difference is that after an insert the requesting panel is null.

After insert:

javascript:Lino.polls.Responses.toggle_choice(null,false,14,{ "fv": [ 2, 32 ] })

On existing record:

javascript:Lino.polls.Responses.toggle_choice("ext-comp-2445",false,14,{ "fv": [ 2, 32 ] })

But that observation doesn’t explain. I activated a few console.log calls in linoweb.js for debugging (all marked 20170731).

But for today I abandon… I checked in everything.