Wednesday, July 20, 2016

I finished adapting the test suites to my changes of the last days.

The event type “System note” is now being created in the demo fixture of lino_xl.lib.notes (and not in std).

TypeError: coercing to Unicode: need string or buffer, NoneType found

I received above error message from a production server and tried to reproduce it. It comes when I select Explorer ‣ Ledger ‣ Accounting periods on that server. The traceback mentions Unprintable AccountingPeriod(pk=6L,error=TypeError('coercing to Unicode: need string or buffer, NoneType found',). So I wrote the following script:

from lino.api.shell import *
obj = ledger.AccountingPeriod.objects.get(pk=6)
print obj

And running it gave:

$ python manage.py run 20160720.py
Traceback (most recent call last):
  ...
  File "20160720.py", line 3, in <module>
    print obj
  File "/local/lib/python2.7/site-packages/django/utils/six.py", line 842, in <lambda>
    klass.__str__ = lambda self: self.__unicode__().encode('utf-8')
AttributeError: 'NoneType' object has no attribute 'encode'

It comes because they created a new period with an empty ref.

  • I removed that bug from the __str__() of lino_xl.lib.ledger.models.AccountingPeriod.

    Wrote a test case for this in lino_cosi.projects.std.tests.test_cosi

  • Created #1062.

‘line__topic’ is an invalid keyword argument for this function

And yet another little bug: #1063 (TypeError: ‘line__topic’ is an invalid keyword argument for this function). This came when some end-user had tried to create an activity into the lino_xl.lib.courses.ui.CoursesByTopic table. We must set allow_create to False on this table because the topic of a course is known only indirectly via the line, and we would not know which activity line to set for a new activity.

A big set of commits

It has been several days that I did not commit because the test suites were broken. Now finally I can show my work to the world ;-) A series of big changesets.

Add checkdata to scheduler

The linod command now also runs checkdata once per day. lino.api.dd.schedule_daily() now specifies a time for running the daily jobs. That time is currently a hard-coded “20:00”. I plan to move linod into its own plugin before making this configurable.

Side effect: I added django and schedule to the default values for auto_configure_logger_names (in different projects).

I also removed the no_local parameter from many settings files. This parameter was no longer used and silently being ignored until now. Now Lino raises a ChangedAPI exception if it happens to be still there.