MobileRead Forums

MobileRead Forums (https://www.mobileread.com/forums/index.php)
-   Plugins (https://www.mobileread.com/forums/forumdisplay.php?f=237)
-   -   Question for plugin development gurus (https://www.mobileread.com/forums/showthread.php?t=167911)

DiapDealer 02-04-2012 11:27 PM

Question for plugin development gurus
 
OK here goes.

I have an old plugin that a couple of people use. I'd like to give it a bit of a face-lift—especially in the GUI configuration department.

I'd really, really, really like to continue using the same plugin name (the internal calibre plugin name), because I want to avoid the situation where someone might have both the old and the new plugin installed at the same time. Plus... consistency. Its value is absolutely immeasurable when it comes to supporting users through email and message boards. ;)

Here's the problem: the old plugin uses the customization string that's accessible through self.site_customization. The updated plugin won't be using that. But when a user (who has the old plugin installed) updates to the new plugin... that old customization info is still in plain sight when viewing the list of installed plugins from calibre's preferences. And since the new plugin isn't configured that way anymore, that customization info is basically stranded there in "calibre limbo" for all time.

Is there any way for me to programmatically do anything to get rid of (or access) that customization info that's stranded in the plugin list view? Ideally, I'd like to be able to handle it (and hopefully import it) when installing the new, updated plugin—but I'm open to any and all possible solutions.

I'd just rather not have to instruct people to delete their customization strings before updating/removing (or even worse; have to tell them that reinstalling the old plugin is the only way they'll even be able to delete it—if they've already removed the old plugin without first wiping out the customization string). And as I first said, installing the new plugin under a different internal calibre name is anything but ideal. A user will inevitably have both versions installed simultaneously which could wreak a lot of havoc on a File Type plugin.

Wow! That was really long.... so sorry. :o Hopefully someone has run into this and has a simple solution? (hope, hope, hope). :D

UPDATE: Actually, I can still access the customization string from the new plugin, but I can't find a way to clear it. It still gets stranded unless someone remembers (or knows) to wipe it before updating.

kovidgoyal 02-04-2012 11:59 PM

Code:

from calibre.customize.ui import config
sc = config['plugin_customization']
val = sc.pop(<plugin name>, None)
if val is not None:
    config['plugin_customization'] = sc


DiapDealer 02-05-2012 12:33 AM

Beautiful! And Quick. Thanks so much! :)

But for anybody that may be reading along... just note that it's "calibre.customize.ui" rather than customization.

Thanks again.


All times are GMT -4. The time now is 08:24 PM.

Powered by: vBulletin
Copyright ©2000 - 3.8.5, Jelsoft Enterprises Ltd.
MobileRead.com is a privately owned, operated and funded community.