From c2b1b59de377e7217755565af58b58691b3a716c Mon Sep 17 00:00:00 2001 From: Martijn Voncken Date: Thu, 17 Jul 2008 18:41:03 +0000 Subject: [PATCH] damoxc patch:set_torrents_options --- deluge/ui/webui/json_api.py | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/deluge/ui/webui/json_api.py b/deluge/ui/webui/json_api.py index e6d0e0af3..0b8847a86 100644 --- a/deluge/ui/webui/json_api.py +++ b/deluge/ui/webui/json_api.py @@ -80,8 +80,11 @@ class json_rpc: * methods : http://dev.deluge-torrent.org/wiki/Development/UiClient#Remoteapi """ #extra exposed methods - json_exposed = ["update_ui","get_stats","system_listMethods"] + json_exposed = ["update_ui","get_stats","set_torrent_options","system_listMethods"] cache = {} + torrent_options = ["trackers","max_connections","max_upload_slots","max_upload_speed", + "max_download_speed","file_priorities","prioritize_first_last","auto_managed","stop_at_ratio", + "stop_ratio","remove_at_ratio"] def GET(self): @@ -207,6 +210,29 @@ class json_rpc: "cache_id":-1 } + def set_torrent_options(self, torrent_id, options_dict): + """ + Composite call. + Goal: limit the number of ajax calls + + input: + {{{ + torrent_id: the id of the torrent who's options are to be changed + options_dict: a dictionary inwhich the options to be changed are contained + }}} + """ + + for option in options_dict: + if option in self.torrent_options: + value = options_dict[option] + if type(value) == str: + try: + value = float(value) + except: + pass + print + func = getattr(sclient, 'set_torrent_' + option) + func(torrent_id, value) def register(): component.get("PageManager").register_page("/json/rpc",json_rpc)