For my current pet project ( just restarted work: Pluginize file naming strategy ), I need to configure a queue of plugins that need to be evaluated in order. One plugin (recreating the current Last name - First name strategy) would stay in the core of Calibre, others would be distributed as zip files like all the other plugins we already have.

Not having too much of python experience, I would imagine that for the configuration, I would store a list of class names in some json file.

For instantiation, I found the following code:

Code:

obj = eval(classname + "()")

somewhere on the 'net. Is this a proper practice? As mentioned above, the solution would need to work with code inside the calibre distribution as well as with plugins added via zip files.

Look at customize/ui.py to see how the various types of plugins are loaded in calibre. It should contain all the code you need to define your plugins.

Thanks for your pointer, in the meantime I managed to create a new plugin type and add them to the "Plugins" menu. I also extracted a bit of code from database2.py and coverted it into a plugin. This class, I can instantiate with

Two other plugins I wrote which conform to the API just defined, I can install into calibre via "calibre-customize -a <filename>.zip". The plugins contain the "plugin-import-name_<foo>.txt" file and __init__.py .

The part which I did not understand yet is how I would initialize such a class of which I might only know the plugin-import-name.