Monday, March 18, 2019

In my yesterday’s changes I didn’t like the way Lino Così was expecting a hoster to specify which VAT declaration plugin to install. My quick solution yesterday asked something like this in your local file:

def get_installed_apps(self):
    yield super(Site, self).get_installed_apps()
    yield 'lino_xl.lib.eevat'

def setup_plugins(self):
    super(Site, self).setup_plugins()

Now it says:

def get_plugin_configs(self):
    yield super(Site, self).get_plugin_configs()
    yield ('vat', 'declaration_plugins', 'lino_xl.lib.eevat')
    yield ('countries', 'hide_region', False)
    yield ('countries', 'country_code', 'EE')
    yield ('ledger', 'use_pcmn', True)

Until now it wasn’t easy to make it that easy because is being called long after IOW it was not easy to say to one plugin (vat) that it should load (or not) some other plugin depending on the value of a configuration setting.

I had to improve the Lino API by adding two new methods and lino.core.plugin.Plugin.get_required_plugins().

TODO: Use configparser and allow for local config files to specify plugin settings.