# Monday, May 16, 2016¶

## Lino documentation now includes Lino XL¶

A fundamental change (but only concerning docs and tests; the code itself is almost not modified): I merged the documentation trees for lino and lino_xl into one single tree. This tree is in a separate code repository lino_book, and all “didactical” projects are now in this repository as well. Main reasons for this change are:

• It is difficult to explain Lino without referring to lino_xl, so we need a “combined” documentation tree.
• The “didactical projects” (e.g. lino_book.projects.min1) are no longer included with the Lino code repository. This is preferrable for people who just want to install and run some Lino application.

As a consequence, many unit tests (those which either are based on doctest or use some of the didactical projects) moved to this new repository.

Note: there is still something broken with the intersphinx links. Many of them currently don’t work. E.g. lino

## Presence sheet (Anwesenheitsblatt)¶

Alexa asked to not cut table cells over two pages, and to render this list in landscape orientation.

In a first step I tried to do this using Google and wkhtmltopdf:

I did not get it to avoid page break inside a rows of table. So once more I see that wkhtmltopdf is not a very good choice when you want to build pdf reports from HTML templates. At least for Lino. It seems that in wkhtmltopdf you cannot specify the page orientation (landscape or portrait) from withing the HTML file.

Since the presence sheet has dynamic columns, it is probably difficult to get this done using appypod.

So I searched for yet another method. And found WeasyPrint. I gave it a try by creating the new plugin lino.modlib.weasyprint. This was not too difficult and revealed already that WeasyPrint has a good API. And yes, it seems that lino.modlib.weasyprint is clearly the winner over lino.modlib.wkhtmltopdf!

It was no problem to avoid page breaks inside table rows, define page orientation and margins. Even a page footer repeating the document title and including the page number. Don’t ask me why wkhtmltopdf can’t do it.

BTW thanks to these pages:

## AttributeError: ‘module’ object has no attribute ‘FFI’¶

The only problem with WeasyPrint was that it depends on Cairo which can be –as they say and as I saw myself– a bit tricky to install. While on my development machine (Debian Trusty) it worked out of the box, I had to do some research for getting it to run on the production server (Debian Jessie) where I had this traceback:

Traceback (most recent call last):
...
File "/repositories/lino/lino/modlib/weasyprint/choicelists.py", line 21, in <module>
from weasyprint import HTML
File "/virtualenvs/a/lib/python2.7/site-packages/weasyprint/__init__.py", line 336, in <module>
from .css import PARSER, preprocess_stylesheet  # noqa
File "/virtualenvs/a/lib/python2.7/site-packages/weasyprint/css/__init__.py", line 30, in <module>
from . import computed_values
File "/virtualenvs/a/lib/python2.7/site-packages/weasyprint/css/computed_values.py", line 18, in <module>
from .. import text
File "/virtualenvs/a/lib/python2.7/site-packages/weasyprint/text.py", line 18, in <module>
import cairocffi as cairo
File "/virtualenvs/a/lib/python2.7/site-packages/cairocffi/__init__.py", line 20, in <module>
from ._ffi import ffi
File "/virtualenvs/a/lib/python2.7/site-packages/cairocffi/_ffi.py", line 4, in <module>
ffi = _cffi_backend.FFI('cairocffi._ffi',
AttributeError: 'module' object has no attribute 'FFI'


This was not the problem reported in cairocffi ‘module’ object has no attribute ‘FFI’ #62 because I can do import cairocffi.

But the discussion Failed to install “Cairocffi” helped me: I “just” had to make sure to have the right version of cairocffi installed:

\$ pip install cairocffi==0.6


## New feature: Print actions with parameters¶

Another problem (back in Lino) was the question how to specify the period to cover on a presence sheet. Our first idea was to use the list parameters. But (a) that was not intuitive and (b) list parameters are not accessible when you open the detail of a course from a hred to it (e.g. using the status report).

So I defined a new action PrintPresenceSheet. This is the first print action with parameters.

This required some minor changes in lino.modlib.printing in order to optimize the API for defining a DirectPrintAction.

And then yet another subtle new feature: an application programmer can now set the new attribute keep_user_values of an action to True. This is important in PrintPresenceSheet when they print a series of presence sheets for different courses. This feature did not even need any change to the Javascript code. Lino.ActionFormPanel.set_field_values just receives an empty dict ({}) in that case.

Another new thing which I guess Alexa is going to love is that I now have a displayfield with the most-used print actions.