View Single Post
Old 06-05-2025, 01:07 AM   #352
Majutsushi
Zealot
Majutsushi knows the difference between 'who' and 'whom'Majutsushi knows the difference between 'who' and 'whom'Majutsushi knows the difference between 'who' and 'whom'Majutsushi knows the difference between 'who' and 'whom'Majutsushi knows the difference between 'who' and 'whom'Majutsushi knows the difference between 'who' and 'whom'Majutsushi knows the difference between 'who' and 'whom'Majutsushi knows the difference between 'who' and 'whom'Majutsushi knows the difference between 'who' and 'whom'Majutsushi knows the difference between 'who' and 'whom'Majutsushi knows the difference between 'who' and 'whom'
 
Posts: 111
Karma: 10128
Join Date: Aug 2023
Location: New Zealand
Device: Kobo Clara HD, Kobo Libra Colour
Quote:
Originally Posted by chaley View Post
It seems to me that the "right" way to do this is to provide a field in KU to set the text form of the series index. That field would be a combination checkbox and template, just as is used in the kobo driver for "collections columns", "collections template", etc. The user would check the box and supply a template that returns the desired string for the series index, which KU would write to the device database. You would need an open database connection to pass to the template processor. Yes, this is specific to series, but that makes it understandable and safe.
This is the kind of change that felt to me would be almost reimplementing plugboards, just with a different output type. I have no idea how the plugboards are implemented or whether the drivers have any influence over them, so I don't know how difficult it would be to make them work in the desired Kobo-specific way, or whether this kind of separate implementation would really be the only way.

Quote:
I strongly advise you not to pass around database connections. There are all sorts of ways where these can lead to disaster, for example when threading. It would also permit a user to rather easily trash the database.
My idea wasn't really about "passing around" database connections as such, at least not in any new way. The method I mentioned already exists for internal use by the plugin, I was just pointing it out. Any use of it by something else would certainly be unsupported and at your own risk, but I would think that someone who knows how to write an ActionChains module would also know how to be careful with database modifications.

As for safety of the connection, if you use the returned connection object as a context manager then it takes a lock and creates a transaction, so it should be safe from that standpoint. I actually suggested the lock feature to Kovid because it was necessary for safely handling the case in Calibre 8 where the database might have been copied to a different location due to filesystem limitations.

So this idea wasn't about creating some official API, just something that people who know what they're doing might use for things that aren't available in the plugin.
Majutsushi is offline   Reply With Quote