View Single Post
Old 02-10-2012, 11:09 AM   #2
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,637
Karma: 2162064
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
There are plenty of examples in the plugins forum if you look at other plugins that work with custom columns, like Reading List, Count Pages, Goodreads Sync that spring to mind.

For instance if you look at the Reading List plugin, in action.py there is an "apply_tags_to_list" function which in that particular case will apply a value to either the tags column or a custom column, depending on which the user has configured. It also reads the value of that column first, using db.get_custom(). In config.py you will find code related to the preferences for the plugin which allow the user to specify which custom column they want updated (something you will want to do for your changes to the APNX plugin as well), so that shows how to get a list of available custom columns by type.

It would also be nice to see the changes you make to the GUI standalone plugin being applied to the file type plugin that ships with Calibre. So that way when people send books to their Kindles using Send to device, it can pull the value from a custom column in the same way (the GUI plugin you mention wouldn't normally be used by people who actually own a Kindle). As I wrote on the Count pages plugin thread, if that functionality was available I might be motivated to support Count Pages pulling page numbers from a website like Goodreads or Amazon as an alternative to estimating by various count algorithms.

If the only reason John didn't do this previously was due to lack of time I don't mind making the changes myself. There is one technical issue with a file type plugin, in that it ordinarily does not have access to the db object (unlike GUI plugins which do through self.gui.current_db). However that can be circumvented with an import that Kovid added a number of months ago to allow any piece of code to get access to the "current" db.

@Kovid - did John discuss this with you at all/do you have any objections to me making the additions to that file type plugin?

Alternatively Saulius - if you want to do both I am happy to leave them both in your hands. I didn't volunteer previously because the plugins were John's work, but since I know he is working hard on Sigil it is all likely pretty low on his priority list.
kiwidude is offline   Reply With Quote