summaryrefslogtreecommitdiffstats
path: root/deluge/ui/web
diff options
context:
space:
mode:
authorCalum Lind <calumlind+deluge@gmail.com>2019-05-09 12:44:30 +0100
committerCalum Lind <calumlind+deluge@gmail.com>2019-05-11 21:04:34 +0100
commit2b171e58a32bed9952da4169a2d47d09182d4470 (patch)
tree73537e948289016a9649b9bd9a3ec91faac95872 /deluge/ui/web
parentd417c4b0f9fd0702ebf986546ab884d2a9517e4e (diff)
downloaddeluge-2b171e58a32bed9952da4169a2d47d09182d4470.tar.gz
deluge-2b171e58a32bed9952da4169a2d47d09182d4470.tar.bz2
deluge-2b171e58a32bed9952da4169a2d47d09182d4470.zip
[Web] Fix missing deregister_object
pluginbase has the complementary deregister_object but the actual method was missing in JSON component.
Diffstat (limited to 'deluge/ui/web')
-rw-r--r--deluge/ui/web/json_api.py26
1 files 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']