From 2b171e58a32bed9952da4169a2d47d09182d4470 Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Thu, 9 May 2019 12:44:30 +0100 Subject: [PATCH] [Web] Fix missing deregister_object pluginbase has the complementary deregister_object but the actual method was missing in JSON component. --- deluge/ui/web/json_api.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/deluge/ui/web/json_api.py b/deluge/ui/web/json_api.py index d760845e6..bfacb5870 100644 --- a/deluge/ui/web/json_api.py +++ b/deluge/ui/web/json_api.py @@ -253,14 +253,15 @@ class JSON(resource.Resource, component.Component): return self._on_json_request_failed(ex, request) def register_object(self, obj, name=None): - """ - Registers an object to export it's rpc methods. These methods should - be exported with the export decorator prior to registering the object. + """Registers an object to export it's rpc methods. + + These methods should be exported with the export decorator prior + to registering the object. + + Args: + obj (object): The object that we want to export. + name (str): The name to use. If None, uses the object class name. - :param obj: the object that we want to export - :type obj: object - :param name: the name to use, if None, it will be the class name of the object - :type name: string """ name = name or obj.__class__.__name__ name = name.lower() @@ -272,6 +273,17 @@ class JSON(resource.Resource, component.Component): log.debug('Registering method: %s', name + '.' + d) self._local_methods[name + '.' + d] = getattr(obj, d) + def deregister_object(self, obj): + """Deregisters an objects exported rpc methods. + + Args: + obj (object): The object that was previously registered. + + """ + for key, value in self._local_methods.items(): + if value.__self__ == obj: + del self._local_methods[key] + FILES_KEYS = ['files', 'file_progress', 'file_priorities']