03-06-2017, 12:14 AM | #196 |
Grand Sorcerer
Posts: 6,234
Karma: 11768331
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Clara/Aura One/Forma,XiaoMI 5, iPad, Huawei MediaPad, YotaPhone 2
|
I'm updating the config like this:
Code:
from calibre.library import db as db_ db = db_() db.prefs.set_namespaced(PREFS_NAMESPACE, PREFS_KEY_SETTINGS, library_config) Last edited by Terisa de morgan; 03-06-2017 at 12:14 AM. Reason: typo |
03-06-2017, 01:05 AM | #197 |
creator of calibre
Posts: 43,860
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
That is the correct API. And it does update both in memory and in db copies. See line 126 of backend.py in the calibre source code.
|
Advert | |
|
03-06-2017, 01:08 AM | #198 |
creator of calibre
Posts: 43,860
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
You are again creating a new db copy. Dont do that. Use the existing db object. If you create a new db copy, the in-memory representations of the preferences are not synced between copies.
|
03-06-2017, 03:02 AM | #199 |
Grand Sorcerer
Posts: 6,234
Karma: 11768331
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Clara/Aura One/Forma,XiaoMI 5, iPad, Huawei MediaPad, YotaPhone 2
|
Problem is, I cannot use it (or I don't know how to access it), as in this case there is no db in the call (FileType plugin)).
|
03-06-2017, 07:50 AM | #200 |
creator of calibre
Posts: 43,860
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
You should not be accessing the db in any filetype callback other than postimport and postadd. The other callbacks can be called in contexts where the db is unavailable/locked.
If you need to store some config options that you need in those callbacks use a config file, dont store them in the db. |
Advert | |
|
03-06-2017, 09:18 AM | #201 | |
Grand Sorcerer
Posts: 6,234
Karma: 11768331
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Clara/Aura One/Forma,XiaoMI 5, iPad, Huawei MediaPad, YotaPhone 2
|
Quote:
|
|
03-07-2017, 12:26 AM | #202 | |
null operator (he/him)
Posts: 20,575
Karma: 26954694
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
Quote:
Code:
"Journals": { "customColumnPath": "", "opcName": "path", "custonColumnExtension": "", "customColumnName": "#camefrom", "customColumnDate": "", } "Media": { "customColumnPath": "", "opcName": "name", "custonColumnExtension": "#orig_ext", "customColumnName": "#orig_name" "customColumnDate": "#orig_mod_date", } BR |
|
03-07-2017, 12:32 AM | #203 |
creator of calibre
Posts: 43,860
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
It's not clear to me why config about which column to store filenames in needs to be accessed outside of postadd/postimport.
|
03-07-2017, 12:52 AM | #204 |
Grand Sorcerer
Posts: 6,234
Karma: 11768331
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Clara/Aura One/Forma,XiaoMI 5, iPad, Huawei MediaPad, YotaPhone 2
|
You have to define the columns at some point but I've changed the way it's managed (it has to access to the database to get the custom columns, it cannot be avoided, but that's all).
|
03-07-2017, 12:54 AM | #205 | |
Grand Sorcerer
Posts: 6,234
Karma: 11768331
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Clara/Aura One/Forma,XiaoMI 5, iPad, Huawei MediaPad, YotaPhone 2
|
Quote:
|
|
03-07-2017, 02:41 AM | #206 | ||
null operator (he/him)
Posts: 20,575
Karma: 26954694
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
Quote:
Quote:
A safer way would be to impose a 'restriction' that the configuration of GFN will apply to all libraries - if the nominated lookup names are present they will be populated, otherwise they won't. BR |
||
03-07-2017, 02:57 AM | #207 | |
Grand Sorcerer
Posts: 6,234
Karma: 11768331
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Clara/Aura One/Forma,XiaoMI 5, iPad, Huawei MediaPad, YotaPhone 2
|
Quote:
I don't like it. I would prefer, if necessary, a default configuration which will apply if no library is found, but no restriction of the same configuration for every library. |
|
03-07-2017, 04:10 AM | #208 |
null operator (he/him)
Posts: 20,575
Karma: 26954694
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
|
03-07-2017, 05:25 AM | #209 | |
creator of calibre
Posts: 43,860
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Quote:
@Terisa: All libraries have a unique id, independint fo the name. db.new_api.library_id Although, if I were you, I'd just not bother with configuration at all and just have it store the data in any custom column named #filename/#filepath. Then its up to the user to create such a column. |
|
03-07-2017, 05:30 AM | #210 |
Grand Sorcerer
Posts: 6,234
Karma: 11768331
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Clara/Aura One/Forma,XiaoMI 5, iPad, Huawei MediaPad, YotaPhone 2
|
kovid, that would solve the problem, thank you very much. And I already have done almost all the work, so I think I'll introduce this small change and that's all, it would be more work going your approach now.
Last edited by Terisa de morgan; 03-07-2017 at 05:33 AM. Reason: typo |
Tags |
calibredb, calibredb metadata import, plugin |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[FileType Plugin] YVES Bible Plugin | ClashTheBunny | Plugins | 27 | 01-16-2023 01:25 AM |
How to sort quickly books by filetype? | construsol | Calibre | 7 | 05-24-2014 06:20 PM |
Calibre associated with every filetype?! | sej7278 | Calibre | 14 | 08-09-2011 10:36 AM |
Zip Filetype Plugin? | rsingley | Plugins | 7 | 02-11-2011 05:11 PM |
How to register a filetype? | plisken | iRex | 2 | 09-28-2009 07:16 AM |