02-18-2011, 05:23 PM | #1 |
calibre/Sigil Developer
Posts: 4,588
Karma: 2089838
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? |
02-18-2011, 05:27 PM | #2 |
creator of calibre
Posts: 43,744
Karma: 22446736
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 | |
|
02-18-2011, 05:39 PM | #3 |
calibre/Sigil Developer
Posts: 4,588
Karma: 2089838
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
|
Thanks Kovid.
|
02-18-2011, 05:45 PM | #4 | |
Grand Sorcerer
Posts: 11,691
Karma: 6240117
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 Tools | Search this Thread |
|
Similar Threads | ||||
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 |