20130710 (Wednesday, 10 July 2013)

Inheriting config directory of another app

Added a new module lino.modlib.auto.sales which extends lino.modlib.trading and is a next example of what I’d call “app inheritance”.

The base sales app is for writing sales invoices, the “auto” sales app is for having Lino automatically generate sales invoices.

It works basically like lino_faggio.contacts (which extends lino.modlib.contacts, see 2013-06-07).

This time there was a new challenge: how can I say that I want to “inherit” the document template for Invoices? The answer is inspired by a technique to extend the Pythonpath: simply add a file config.pth (the name must end with .pth) to the app’s directory (i.e. the directory which contains the models.py file). This file should contain one line for each additional config dir to add.

Lino-Faggio continued

  • lino_xl.lib.cal.Event and lino_xl.lib.cal.Room are now overridable.

  • lino_faggio uses this to make Events invoiceable

  • cal.Room is no longer a ContactRelated by default because many applications don’t need this. lino_faggio overrides it to make it ContactRelated.

  • lino_faggio now also adds new fields Event.organizer cal.Room.tariff

  • New app lino_faggio.cal extends lino_xl.lib.cal

Inheriting config directory of another app (continued)

After having checked in the above changes, I understood that we don’t want an additional file config.pth:

  • that’s one file more

  • it doesn’t work for making lino_faggio.cal inherit the config of lino_xl.lib.cal (because the former cannot easily know the path of the latter).

The new approach is to use magic module-level variable PARENT_APP which holds as a string the full Python name of the parent app. I also want this to happen in the models module and not in the app’s __init__.py file. A side effect is that I cannot any longer import mod:lino.utils.config at the global level of a models module because importing it will fill the config dirs, i.e. will try to import every installed models module.

Added new function lino.dd.extends_app(). To have lino_faggio.cal extend lino_xl.lib.cal, we now need only one line of code:

dd.extends_app('lino.modlib.trading',globals())

Lino-Faggio continued

  • Renamed lino.modlib.school to lino.modlib.courses.

  • New module lino_faggio.courses extends lino.modlib.courses.

  • Repaired test suites

Is it a demo site or not?

There are meanwhile at least three different versions of admin_main.html templates, partly with overlapping content, and already there are some subtle bugs.

The admin_main.html has sections that are important on a public demo site, but certainly not on a production site. For example the list of possible user names and their password:

<p>
{{_("This demo site has %d users, they all have \"1234\" as password:") %
site.modules.users.UsersOverview.request().get_total_count()}}
</p>
{{as_ul('users.UsersOverview')}}

Or (on another place of the template):

<p>
{{_("Your feedback is welcome to <em>lino-users@googlegroups.com</em> or directly to the person who invited you.")}}
</p>

Solution:

Checkin and upgrade on The Lino framework.