View Single Post
Old 06-19-2012, 06:05 AM   #1
kiwidude
Calibre Plugins Developer
kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.
 
Posts: 4,731
Karma: 2197770
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
Storing plugin data for multi-machine usage

A post today on the Reading List plugin has prompted me to rethink about how I store per library plugin data in particular, and I am interested to know what options exist in calibre today and what might be considered adding for it.

Right now every plugin I have written at least uses a local json file in the plugins folder to store all its data. It is the highest performance, most convenient to develop with, not impacted by people rebuilding their libraries and allows library-agnostic setting storage. Given that calibre also serializes a lot of configuration style data into the same directory area it seemed a reasonable approach at the time at least.

However with Kovid changing the back-end to one day support calibre being used from multiple machines, to an end-user this approach becomes a rather inconvenient if not downright flawed one. Certainly there can be some settings which you would keep machine specific, for which the json file remains a good choice. But there are also plugin settings a user will want to share across their machines. Some may still be library agnostic (such as configuring Search the Internet menus or Generate Cover settings) - the user can use features I have written within the plugins to import/export between their machines as a workaround. However others have library specific data such as reading lists which screams out to be stored in the library database.

Right now the data storage options from a plugin I am aware of are:
  • private file storage, such as the json files, local resource images etc
  • in-memory storage ("marked data"), only for temporary per book data, used by many plugins such as Quality Check
  • library database per book storage in a custom column.
  • library database per book storage ("custom book data"), used by Find Duplicates to store computed hashes for performance reasons.
Anything else I have forgotten/don't know about? Specifically there are two more kinds of storage that might be desirable or else have to be simulated using the above:
  • library database storage that is not per book, allowing a plugin to serialise a dict of values. For instance an ordered list of book ids for the reading list plugin, or custom column names assigned to specific functions.
  • cross-library storage. Today calibre does this using files in its configuration directory, which will become a potential problem for users with multiple computers. They can put their library in a shared folder, but what about sharing their calibre settings and the implications thereof? Perhaps my import/export approach is the only "practical" solution.
Appreciate any thoughts...

Last edited by kiwidude; 06-19-2012 at 06:11 AM.
kiwidude is offline   Reply With Quote