Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Plugins

Notices

Reply
 
Thread Tools Search this Thread
Old 03-06-2017, 12:14 AM   #196
Terisa de morgan
Grand Sorcerer
Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.
 
Terisa de morgan's Avatar
 
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)
As in the other plugins (not the first part). I'll try to find the config API.

Last edited by Terisa de morgan; 03-06-2017 at 12:14 AM. Reason: typo
Terisa de morgan is offline   Reply With Quote
Old 03-06-2017, 01:05 AM   #197
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
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.
kovidgoyal is offline   Reply With Quote
Advert
Old 03-06-2017, 01:08 AM   #198
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
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.
kovidgoyal is offline   Reply With Quote
Old 03-06-2017, 03:02 AM   #199
Terisa de morgan
Grand Sorcerer
Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.
 
Terisa de morgan's Avatar
 
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:
Originally Posted by kovidgoyal View Post
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.
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)).
Terisa de morgan is offline   Reply With Quote
Old 03-06-2017, 07:50 AM   #200
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
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.
kovidgoyal is offline   Reply With Quote
Advert
Old 03-06-2017, 09:18 AM   #201
Terisa de morgan
Grand Sorcerer
Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.
 
Terisa de morgan's Avatar
 
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:
Originally Posted by kovidgoyal View Post
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.
Yes, I'm understanding this, and I must store the configuration for each library in the file, yes.
Terisa de morgan is offline   Reply With Quote
Old 03-07-2017, 12:26 AM   #202
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 20,575
Karma: 26954694
Join Date: Mar 2012
Location: Sydney Australia
Device: none
Quote:
Originally Posted by Terisa de morgan View Post
Yes, I'm understanding this, and I must store the configuration for each library in the file, yes.
So %CALIBRE_CONFIG_DIRECTORY%\plugins\getfilename.jso n, would have something like:

Code:
"Journals": {
    "customColumnPath": "", 
    "opcName": "path", 
    "custonColumnExtension": "", 
    "customColumnName": "#camefrom", 
    "customColumnDate": "", 
}
"Media": {
    "customColumnPath": "", 
    "opcName": "name", 
    "custonColumnExtension": "#orig_ext", 
    "customColumnName": "#orig_name"
    "customColumnDate": "#orig_mod_date", 
}
If a library is renamed the plugin will probably stop saving the file details - as happened to me last December? If the user doesn't show the columns in the book list or book details sidebar it could be weeks or months before they noticed - I didn't notice until late January.

BR
BetterRed is offline   Reply With Quote
Old 03-07-2017, 12:32 AM   #203
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
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.
kovidgoyal is offline   Reply With Quote
Old 03-07-2017, 12:52 AM   #204
Terisa de morgan
Grand Sorcerer
Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.
 
Terisa de morgan's Avatar
 
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:
Originally Posted by kovidgoyal View Post
It's not clear to me why config about which column to store filenames in needs to be accessed outside of postadd/postimport.
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).
Terisa de morgan is offline   Reply With Quote
Old 03-07-2017, 12:54 AM   #205
Terisa de morgan
Grand Sorcerer
Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.
 
Terisa de morgan's Avatar
 
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:
Originally Posted by BetterRed View Post
If a library is renamed the plugin will probably stop saving the file details - as happened to me last December? If the user doesn't show the columns in the book list or book details sidebar it could be weeks or months before they noticed - I didn't notice until late January.

BR
In a file? Yes, that's one of the reasons I wanted to store it in the database but it looks like it cannot be avoided, and I see no way to correct this (anyway, to rename a library is not a common event).
Terisa de morgan is offline   Reply With Quote
Old 03-07-2017, 02:41 AM   #206
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 20,575
Karma: 26954694
Join Date: Mar 2012
Location: Sydney Australia
Device: none
Quote:
Originally Posted by Terisa de morgan View Post
In a file? Yes, that's one of the reasons I wanted to store it in the database
Appreciate that, like all the other PIs that have column lookup names in their configurations - View Manager, Count Pages, Reading List, etc.

Quote:
Originally Posted by Terisa de morgan View Post
but it looks like it cannot be avoided, and I see no way to correct this (anyway, to rename a library is not a common event).
I guess it's because it's a File Type plugin, the others are User Interface plugins.

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
BetterRed is offline   Reply With Quote
Old 03-07-2017, 02:57 AM   #207
Terisa de morgan
Grand Sorcerer
Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.
 
Terisa de morgan's Avatar
 
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:
Originally Posted by BetterRed View Post
Appreciate that, like all the other PIs that have column lookup names in their configurations - View Manager, Count Pages, Reading List, etc.


I guess it's because it's a File Type plugin, the others are User Interface plugins.
Yes, a GUI plugin has a direct access to the database at any moment, a file plugin no.

Quote:
Originally Posted by BetterRed View Post
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
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.
Terisa de morgan is offline   Reply With Quote
Old 03-07-2017, 04:10 AM   #208
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 20,575
Karma: 26954694
Join Date: Mar 2012
Location: Sydney Australia
Device: none
Quote:
Originally Posted by Terisa de morgan View Post
Yes, a GUI plugin has a direct access to the database at any moment, a file plugin no.
Devil's Advocate asks, "Why not? And could it be made so? And if not, why not?"

BR
BetterRed is offline   Reply With Quote
Old 03-07-2017, 05:25 AM   #209
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,860
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Quote:
Originally Posted by BetterRed View Post
Devil's Advocate asks, "Why not? And could it be made so? And if not, why not?"
BR
Because they can run in places where there is no db, such as the command line tools on a system with no library.

@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.
kovidgoyal is offline   Reply With Quote
Old 03-07-2017, 05:30 AM   #210
Terisa de morgan
Grand Sorcerer
Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.
 
Terisa de morgan's Avatar
 
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
Terisa de morgan is offline   Reply With Quote
Reply

Tags
calibredb, calibredb metadata import, plugin


Forum Jump

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


All times are GMT -4. The time now is 01:43 PM.


MobileRead.com is a privately owned, operated and funded community.