View Single Post
Old 01-04-2012, 08:58 AM   #1
hakan42
Zealot
hakan42 is on a distinguished road
 
hakan42's Avatar
 
Posts: 136
Karma: 60
Join Date: Jul 2009
Location: Munich, Germany
Device: Nook Classic rooted; Galaxy S IV with Aldiko, other older devices
How do I instantiate new plugins?

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.
hakan42 is offline   Reply With Quote