Register Guidelines E-Books Search Today's Posts Mark Forums Read

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

Notices

Reply
 
Thread Tools Search this Thread
Old 02-18-2011, 05:23 PM   #1
kiwidude
calibre/Sigil Developer
kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.
 
Posts: 4,224
Karma: 1334002
Join Date: Oct 2010
Location: London, UK
Device: Kindle Paperwhite 3G, iPad 3, iPad Air
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?
kiwidude is offline   Reply With Quote
Old 02-18-2011, 05:27 PM   #2
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: 25,663
Karma: 4998489
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.
kovidgoyal is offline   Reply With Quote
Old 02-18-2011, 05:39 PM   #3
kiwidude
calibre/Sigil Developer
kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.
 
Posts: 4,224
Karma: 1334002
Join Date: Oct 2010
Location: London, UK
Device: Kindle Paperwhite 3G, iPad 3, iPad Air
Thanks Kovid.
kiwidude is offline   Reply With Quote
Old 02-18-2011, 05:45 PM   #4
chaley
"chaley", not "charley"
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 5,205
Karma: 821512
Join Date: Jan 2010
Location: France
Device: Many android devices
Quote:
Originally Posted by kiwidude View Post
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?
has_id is extremely fast, simply testing the existence of x[id] in a list. If using has_id solves your problem, then go for it.

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.
chaley is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

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


All times are GMT -4. The time now is 05:54 AM.


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