Lino has a concept of configuration directories that are a bit like Django's templates directories.
This is a tested document. The following instructions are used for initialization:
>>> import os >>> os.environ['LINO_CACHE_ROOT'] = '' # disable for this doctest >>> from lino import startup >>> startup('lino_book.projects.confdirs.settings') >>> from lino.api.doctest import *
holds a singleton instance of
is the registry for config directories. It is initialized once at startup.
A directory named
configthat is collected at startup into a list of directories to be searched when looking for configuration files.
- plugin configuration directory
configdirectory in the source directory of a plugin.
- site configuration directory
- local configuration directory
A site configuration directory that contains locally customized template files.
Site config dirs are searched before plugin config dirs.
>>> settings.SITE.confdirs <lino.utils.config.ConfigDirCache object at ...>
>>> for cd in settings.SITE.confdirs.config_dirs: ... print(cd.name, cd.writeable) /.../lino_book/projects/confdirs/config True /.../lino_xl/lib/contacts/config False /.../lino/modlib/users/config False /.../lino/modlib/printing/config False /.../lino/modlib/extjs/config False /.../lino/modlib/bootstrap3/config False /.../lino/modlib/jinja/config False /.../lino/config False
>>> rt.find_config_file('admin_main.html') '.../lino_book/projects/confdirs/config/admin_main.html'
Some end users want to be able to configure themselves certain templates.
First step : make a local copy of the relevant templates:
$ go mysite $ cp -a env/lib/python3.6/site-packages/lino_xl/lib/sales/config .
Second step: make the local config directory accessible to the end user via SSH or WebDAV or any other method.
Here is a typical workflow for a local template optimization.
Some user wants some change in a printed output.
The template manager needs to know a database object that serves as example.
Figure out how to clear the cache and rebuild the printable document without creating useless database content such as new excerpts.
Find out which file is being used as template. Look at the
lino.logif you have no idea where to start.
Create a backup copy of the template file.
Make some change, save the template file, rebuild the printable.
When you are satisfied, remove the backup file.
lino_book.projects.apc demo project has a site config dir.
This is our demo case of a local config dir.
apc tests were run on travis (i.e.
LINO_CACHE_ROOT is set), Lino
forgot to add the apc site's config dir to its list of config dirs. Another
problem was that these "non-local site config dirs" (for which apc on travis is
the only example) must come before the plugin config dirs. See