Welcome | Get started | Dive into Lino | Contribute | Topics | Reference | More

About cached temporary data

When you run a Lino application, Lino needs a place for storing temporary files like the SQLite database file, static files and dynamically generated files of miscellaneous types like .js, .pdf, .xls.

In a normal development environment this is simply below the project directory, and those cache files are simply listed in the .gitignore file.

But e.g. on Travis CI it is not allowed to write to the code repository.

In such situations you create an empty directory where you have write permission, and then set the LINO_CACHE_ROOT environment variable to point to it.

The safest place for this directory is below your virtual environment:

$ cd ~/virtualenvs/a
$ mkdir lino_cache

And then to add the following line to your ~/virtualenvs/a/bin/activate script:

export LINO_CACHE_ROOT=$VIRTUAL_ENV/lino_cache

Don't forget to re-run the script in order to activate these changes. You can verify whether the variable is set using this command:

$ set | grep LINO
LINO_CACHE_ROOT

If an environment variable LINO_CACHE_ROOT is set, then the cached data of a Lino project (e.g. the default.db files and the media directory) are not written into the file tree of the source code repository but below the given directory.

For example you can add the following line to your .bashrc file:

export LINO_CACHE_ROOT=/home/luc/tmp/cache

Note that the path should be absolute and without a ~.

When you use a LINO_CACHE_ROOT it can happen that the names of your demo projects clash. In that case you can manually set a different project_name

See also lino.core.site.Site.site_dir.

When to update your static files

(This section is probably obsolete. Don't read.)

collectstatic

Lino comes with over 4000 static files, and together they take about 50 MB of hard disk storage. To manage them, it uses Django's staticfiles app, which provides the collectstatic command.

Django applications expect static files to be stored in a central directory pointed to by STATIC_ROOT. And the development server automatically serves them at the location defined in STATIC_URL.

Lino automatically sets STATIC_ROOT to a directory named collectstatic under your LINO_CACHE_ROOT.

As we said in Create your first Lino site, before you can see your first Lino application running in a web server on your machine, you must run Django's collectstatic command:

$ python manage.py collectstatic

Theoretically you need to do this only for your first local Lino project, but you should run collectstatic again:

  • after a Lino upgrade

  • when you changed your LINO_CACHE_ROOT

  • if you use a plugin with static files for the first time

The following built-in plugins have static files:

You can run the collectstatic command as often as you want. So if you are in doubt, just run it again.

Site settings

Some attributes of your Site instance which are related to this topic:

Django settings

Some Django settings related to this topic:

STATIC_ROOT

The root directory where static files are to be collected when the collectstatic command is run. See Django doc.

This is not needed as long as you work on a development server because the developement server serves static files automagically.

If this is not set, Lino sets an intelligent default value for it as follows.

When LINO_CACHE_ROOT is set, the default value for STATIC_ROOT is a subdir named collectstatic of LINO_CACHE_ROOT. Otherwise it is set to a subdir named static of the site_dir.

MEDIA_ROOT

The root directory of the media files used on this site. If the directory specified by MEDIA_ROOT does not exist, then Lino does not create any cache files. Which means that the web interface won't work.

Used e.g. by lino.utils.media lino.modlib.extjs and lino.mixins.printable.