![]() |
#1 |
Calibre Plugins Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,724
Karma: 2197770
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
|
database2.py deletion notifications
Is the notify=True argument on the majority of functions in database2.py historical code, for future usage, or just selectively used?
I wanted to get notifications about rows being deleted in my plugin so that I could update some id mapping caches I maintain. However I see that while all the infrastructure is there, the call to delete_book sets notify=False. Further searches revealed only one call to add_event_listener in the codebase, and that was in tag_viewer.py which responded to any notification it might receive. In the end I chose an approach of db.data.has_id() when I retrieve an id from my cache to verify it is still valid and remove it if not. Anything else I could/should have done instead? |
![]() |
![]() |
![]() |
#2 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,231
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
IIRC it's used in a couple of places. It was originally going to be much more comprehensively used, but there turned out to be not much need for it.
Historically the in memory cache was not nearly as comprehensive as it is now, and so querying for existence was much more costly than it is now. |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Calibre Plugins Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,724
Karma: 2197770
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
|
Thanks Kovid.
|
![]() |
![]() |
![]() |
#4 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,354
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
We might consider a publish and subscribe interface on db.data, calling the supplied subscription method whenever the cache changes. An interface at the cache level would be lower-level than the current notifier and possibly more accurate, signaling deletions, additions, and replacements. However, I don't think we should do this until (if and when) we have more cases where it would be used, because changing the interface after it is used would be a genuine bother. |
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Wireless (email) delivery and automatic deletion? | kidblue | Calibre | 7 | 10-08-2010 11:11 AM |
Multi-select pages for deletion? | neonbible | Sigil | 3 | 09-09-2010 09:37 PM |
Daily notifications? | devilsadvocate | Feedback | 8 | 01-22-2010 12:24 PM |
Format deletion | jbjb | Calibre | 8 | 11-29-2008 12:18 PM |
Ereader.com account deletion | jadedboi | Reading and Management | 1 | 06-07-2006 02:13 PM |