Saturday, September 20, 2014

Two API changes

Oops, here is an API change which caused me some code changes. But I think it was worth the work because it makes things much more clear. And there is hope that other developers didn’t yet use it very much since it was not yet documented clearly:

I added a new module lino.rt and moved the following functions and objects from lino.dd to it:

  • rt.startup()

  • rt.models

  • rt.login()

  • rt.show()

And then I did another thing which had been waiting in my mind for quite some time:

  • The objects stored in rt.models are no longer AttrDict instances but the models.py modules themselves.

My general impression is that this makes Lino more beautiful because it is “one strange thing less”.

This change should officially not influence any code, but there exceptions when it comes to hackerish usages. For example certain tested tutorial documents (like https://www.lino-framework.org/tutorials/tables/index.html) used a trick to put the names of models and tables to the global namespace:

>>> from lino.api.shell import *
>>> globals().update(tables)

This hack has become different:

>>> from lino.api.shell import *
>>> globals().update(tables.__dict__)

Remote fields failed on empty values

Discovered and fixed a bug in Lino which occured in Renamed “Lino Faggio” to “Lino Voga”. After creating a new room, I got the following console message, and the list of rooms no longer appeared at all:

[20/Sep/2014 20:20:44] "GET /api/cal/Rooms/-99999?_dc=1411233644184&an=insert&rp=ext-comp-2235&fmt=json HTTP/1.1" 200 426
ERROR 'NoneType' object has no attribute 'city'
Traceback (most recent call last):
  File "/home/luc/hgwork/lino/lino/core/model.py", line 150, in func
    obj, ar)
  File "/home/luc/hgwork/lino/lino/ui/store.py", line 191, in full_value_from_object
    return getattr(obj, self.name)
AttributeError: 'NoneType' object has no attribute 'city'
WARNING AjaxExceptionResponse:
AttributeError
'str' object has no attribute 'pk'

Wrote a new test case to reproduce this: Calendar functionality in Lino Voga. The reason was a bug in lino.core.fields.RemoteField triggered by the company__city column in the ml.cal.Rooms list (but only the Renamed “Lino Faggio” to “Lino Voga” variant of it.