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):
|
def add_listener(self, event_callback_function):
|
||||||
'''
|
'''
|
||||||
Register a callback function that will be called after certain actions are
|
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
|
taken on this database. The function must take three arguments:
|
||||||
which is the event type (:class:`EventType`) and the second is a tuple
|
(:class:`EventType`, library_id, event_type_specific_data)
|
||||||
containing 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)
|
self.event_dispatcher.add_listener(event_callback_function)
|
||||||
|
|
||||||
@write_api
|
@write_api
|
||||||
|
@ -46,6 +46,7 @@ class EventDispatcher:
|
|||||||
self.refs = []
|
self.refs = []
|
||||||
self.queue = Queue()
|
self.queue = Queue()
|
||||||
self.activated = False
|
self.activated = False
|
||||||
|
self.library_id = ''
|
||||||
|
|
||||||
def add_listener(self, callback):
|
def add_listener(self, callback):
|
||||||
# note that we intentionally leak dead weakrefs. To not do so would
|
# note that we intentionally leak dead weakrefs. To not do so would
|
||||||
@ -66,7 +67,7 @@ class EventDispatcher:
|
|||||||
|
|
||||||
def __call__(self, event_name, *args):
|
def __call__(self, event_name, *args):
|
||||||
if self.activated:
|
if self.activated:
|
||||||
self.queue.put((event_name, args))
|
self.queue.put((event_name, self.library_id, args))
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
if self.activated:
|
if self.activated:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user