Thursday, February 7, 2019

I started to implement the new lino_xl.lib.files plugin for #2826 and –as usual– my original plan changed. E.g. volumes are not stored in a choicelist but in a database table. And the funniest: we don’t even need a files plugin, we just add a Volume model to lino.modlib.uploads and two fields to the lino.modlib.uploads.Upload model! The filenames of the combobox are simply generated for every request using os.walk(). See tomorrow for a summary of the changes.

Did you know that there are two variants of the upload plugin:

lino_xl.lib.uploads extends the core variant by adding a valididty date and reminders. We won’t need this for Lino Così.

I had to refresh my memory about os.walk():

cd /home/luc
mkdir shared
mkdir shared/foo
mkdir shared/foo/bar
touch shared/index.txt
touch shared/foo/index.txt
touch shared/foo/bar/index.txt
touch shared/foo/bar/baz.txt
>>> import os
>>> for (root, dirs, files) in os.walk("/home/luc/shared"):
...     print(root, dirs, files)
('/home/luc/shared', ['foo'], ['index.txt'])
('/home/luc/shared/foo', ['bar'], ['index.txt'])
('/home/luc/shared/foo/bar', [], ['baz.txt', 'index.txt'])