mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Also add the library id when dispatching events
This commit is contained in:
parent
559d467556
commit
d3681ca528
@ -427,10 +427,10 @@ class Cache(object):
|
||||
def add_listener(self, event_callback_function):
|
||||
'''
|
||||
Register a callback function that will be called after certain actions are
|
||||
taken on this database. The function must take two arguments, the first of
|
||||
which is the event type (:class:`EventType`) and the second is a tuple
|
||||
containing event type specific data.
|
||||
taken on this database. The function must take three arguments:
|
||||
(:class:`EventType`, library_id, event_type_specific_data)
|
||||
'''
|
||||
self.event_dispatcher.library_id = getattr(self, 'server_library_id', self.library_id)
|
||||
self.event_dispatcher.add_listener(event_callback_function)
|
||||
|
||||
@write_api
|
||||
|
@ -46,6 +46,7 @@ class EventDispatcher:
|
||||
self.refs = []
|
||||
self.queue = Queue()
|
||||
self.activated = False
|
||||
self.library_id = ''
|
||||
|
||||
def add_listener(self, callback):
|
||||
# note that we intentionally leak dead weakrefs. To not do so would
|
||||
@ -66,7 +67,7 @@ class EventDispatcher:
|
||||
|
||||
def __call__(self, event_name, *args):
|
||||
if self.activated:
|
||||
self.queue.put((event_name, args))
|
||||
self.queue.put((event_name, self.library_id, args))
|
||||
|
||||
def close(self):
|
||||
if self.activated:
|
||||
|
Loading…
x
Reference in New Issue
Block a user