02-26-2011, 04:55 PM | #1 |
Sigil developer
Posts: 1,274
Karma: 1101600
Join Date: Jan 2011
Location: UK
Device: Kindle PW, K4 NT, K3, Kobo Touch
|
Library names
Is there a library code/number/id stored for a library besides the library's name, that can be accessed via a function call?
I'm looking at storing configuration data per library - so separate entries in the json file for each library. I can use the library name - but if the user renames the library, then they 'loose' the customizations (they could edit the json file of course). |
02-26-2011, 05:16 PM | #2 |
Grand Sorcerer
Posts: 11,775
Karma: 7029857
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Not that I know of.
It would be possible to store a UUID in db.prefs. This is something to take up with Kovid. |
Advert | |
|
02-26-2011, 09:38 PM | #3 |
creator of calibre
Posts: 43,999
Karma: 22669822
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
If you want to store per library settings, you should store the settings in the library. Use the interface in database2 for storing plugin settings.
|
02-27-2011, 03:22 AM | #4 | |
Grand Sorcerer
Posts: 11,775
Karma: 7029857
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
That aside, it might be a good idea to have a library UUID. Such a thing would help validation of persistent caches, and could be useful in the face of library renames verifying which operations have been done to which libraries. It is true that copying a library outside of calibre would duplicate UUIDs, but as it would duplicate anything else, I don't see that as a deal-breaker. |
|
02-27-2011, 04:19 AM | #5 |
Sigil developer
Posts: 1,274
Karma: 1101600
Join Date: Jan 2011
Location: UK
Device: Kindle PW, K4 NT, K3, Kobo Touch
|
I see how to set/get the data in the DB, although like Chaley I'm a little hesitant.
Is there a naming convention I should use for plugin data (# is user, @ is category, etc.), e.g. name_plugin_setting, or plugin_MyName_setting, etc. to avoid clashes. This data will be persistent after the plugin is removed, and unlike a file can't be deleted. I suppose I could provide a delete customizations button on the customization window like reset all which could be used before the plugin is removed. The reason I want to do settings per library is because the columns/categories change per library - and if I use a file that's not aware of libraries then the old data would get re-written on each library switch. I guess if the library did contain a unique ID, if you just copied it as mentioned, then I couldn't tell the difference between the 2 libraries based on the ID (unless to 'copy' a db you had to export it and this cleared the ID). In my customization window I could provide a 'Library name' which could be overridden by the user in case of a rename. These are likely to be rare with this plugin, but its interesting to make sure the plugin is flexible - but not confusing to the user. I'm also debating how to store config settings per device. Either I put the config settings on the device (JSONConfig forces the path to be in Calibre's config_dir so I'd have to use my own version), or I store the device name in a central settings store. But since the Kindle has no unique identifier accessible to me, I'd have to store a name in a file anyway, or just allow the user to select a profile (or most likely a combination of default name/selection). I was just about to finish testing too - always one more thing to go in before the next version |
Advert | |
|
02-27-2011, 04:55 AM | #6 |
Calibre Plugins Developer
Posts: 4,647
Karma: 2162064
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
|
I'll be interested to see any outcome of this discussion. The only plugin that I have written to date that persists what could be considered library specific information is the new Goodreads sync plugin. In theory a user could want to specify different sync action custom columns for different libraries which would be a problem. However given that a shelf sync requires all the books to be in the same library it really isn't very likely.
That is not to say that there aren't other plugins I may write in future which may have the same challenge of course. |
02-27-2011, 09:54 AM | #7 |
creator of calibre
Posts: 43,999
Karma: 22669822
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
If you're storing the prefs in the db, then prefix your variable name with the plugin name.
We can certainly add a uuid to the db. I'll do this when I modify the schema for the identifiers table. |
02-27-2011, 10:34 AM | #8 |
Sigil developer
Posts: 1,274
Karma: 1101600
Join Date: Jan 2011
Location: UK
Device: Kindle PW, K4 NT, K3, Kobo Touch
|
OK. I think I'll leave out the multiple library/multiple Kindle for now as there's enough to test and I need to consider how to do both multiple libraries and multiple devices. (not sure if you are updating the identifier's table any time soon).
There doesn't appear to be a uuid for the device saved in metadata.calibre so I'll have to manage separate ones in some other way. |
02-27-2011, 10:47 AM | #9 |
creator of calibre
Posts: 43,999
Karma: 22669822
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
No, there is no uuid saved in metadata.calibre, though I suppose that could be changed as well, I'll leave that to chaley to comment on.
|
02-27-2011, 11:33 AM | #10 |
Grand Sorcerer
Posts: 11,775
Karma: 7029857
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Are you suggesting that a UUID stored in metadata.calibre be a proxy for a device ID? The difficulty is it's transience; if the file is deleted or damaged, then a new UUID will be assigned. Would the application be able to recover from that?
|
02-27-2011, 11:46 AM | #11 |
Sigil developer
Posts: 1,274
Karma: 1101600
Join Date: Jan 2011
Location: UK
Device: Kindle PW, K4 NT, K3, Kobo Touch
|
Is there a device ID available from somewhere?
I was just looking for some way to say that Kindle X is attached so that I could recognize it the next time it attaches to present just its configuration settings. If the device had no ID I guess I would default to using a default name and present/update the default settings. I don't know if metadata.calibre is the right place for it (I see it uses a straight list of books so I don't know if you could add a new key without messing up anything that reads it. That might not be many programs - it would break my 1.3.3 version, but not my next one if I ever get it done ) If a uuid was saved, it might need a name too, although that might not be needed in my case (I would just present settings based on which Kindle was attached and save according to uuid and library uuid). I notice in kiwidude's Book Sync plugin he also mentions lack of multiple device support. I think he just uses 1 list to sync whichever Kindle is next attached. To use multiple would require presenting a list to select from - and choosing from 1aX7 versus 2b84 might not be intuitive to users |
02-27-2011, 12:26 PM | #12 |
creator of calibre
Posts: 43,999
Karma: 22669822
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Some devices have serial numbers some dont. The Kindle's do, IIRC, but calibre only reads that info on OSX and linux, not windows.
|
02-27-2011, 12:27 PM | #13 | ||
Grand Sorcerer
Posts: 11,775
Karma: 7029857
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Not that I know of.
Quote:
Quote:
|
||
02-27-2011, 12:55 PM | #14 |
Wizard
Posts: 3,130
Karma: 91256
Join Date: Feb 2008
Location: Germany
Device: Cybook Gen3
|
I know the discussion has drifted a little, and I'm no developer, but I just had an idea re managing plugin config stored in the db: I don't know if there is one already, but shouldn't it be possible to add an uninstall function to plugins that gets called when the user selects to remove the plugin via the plugins dialog? That way, each plugin could (and should) clean up after itself before it gets removed.
|
02-27-2011, 01:16 PM | #15 | |
creator of calibre
Posts: 43,999
Karma: 22669822
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Quote:
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How do you pick names? | AgentBEATS | Writers' Corner | 32 | 02-22-2011 10:03 AM |
Confused about names | shinnosuke | BeBook | 8 | 04-24-2010 11:33 AM |
Publisher's Names | emonti8384 | General Discussions | 10 | 04-05-2010 12:05 AM |
Author names | superplinio | Calibre | 6 | 02-27-2010 04:58 AM |
Help me out with a couple of names | ardeegee | Lounge | 12 | 09-27-2009 03:41 AM |