Fix event handler de/registering

This commit is contained in:
Andrew Resch 2009-04-19 19:50:12 +00:00
parent b60dc2d4ca
commit 2589baf0e2

View File

@ -321,9 +321,11 @@ class DaemonSSLProxy(DaemonProxy):
if event not in self.__factory.event_handlers: if event not in self.__factory.event_handlers:
# This is a new event to handle, so we need to tell the daemon # This is a new event to handle, so we need to tell the daemon
# that we're interested in receiving this type of event # that we're interested in receiving this type of event
self.event_handlers[event] = [] self.__factory.event_handlers[event] = []
self.call("daemon.set_event_interest", [event]) self.call("daemon.set_event_interest", [event])
# Only add the handler if it's not already registered
if handler not in self.__factory.event_handlers[event]:
self.__factory.event_handlers[event].append(handler) self.__factory.event_handlers[event].append(handler)
def deregister_event_handler(self, event, handler): def deregister_event_handler(self, event, handler):
@ -334,8 +336,8 @@ class DaemonSSLProxy(DaemonProxy):
:param handler: function, the function registered :param handler: function, the function registered
""" """
if event in self.event_handlers and handler in self.event_handlers[event]: if event in self.__factory.event_handlers and handler in self.__factory.event_handlers[event]:
self.event_handlers[event].remove(handler) self.__factory.event_handlers[event].remove(handler)
def __rpcError(self, error_data): def __rpcError(self, error_data):
""" """