diff --git a/deluge/ui/webui/config_forms.py b/deluge/ui/webui/config_forms.py index fa2eeba8a..5a411ed25 100644 --- a/deluge/ui/webui/config_forms.py +++ b/deluge/ui/webui/config_forms.py @@ -36,7 +36,7 @@ from deluge.ui.client import sclient as proxy from deluge.log import LOG as log from render import render -from web import seeother +from utils import seeother import sys import os import utils diff --git a/deluge/ui/webui/deluge_webserver.py b/deluge/ui/webui/deluge_webserver.py index 1138c019f..398cea266 100644 --- a/deluge/ui/webui/deluge_webserver.py +++ b/deluge/ui/webui/deluge_webserver.py @@ -79,11 +79,9 @@ config_forms.register() #/self registering pages. -utils.set_config_defaults() -sclient.set_core_uri(config.get('daemon')) - - -def WsgiApplication(middleware): +def WsgiApplication(middleware = None): + if not middleware: + middleware = [] from web import webpyfunc, wsgifunc from deluge import component @@ -92,17 +90,21 @@ def WsgiApplication(middleware): def WebServer(debug = False): "starts builtin webserver" + + utils.set_config_defaults() + config.set('base','') + config.set('disallow',{}) + utils.apply_config() + import web from lib.gtk_cherrypy_wsgiserver import CherryPyWSGIServer - if debug: middleware = [web.reloader] else: middleware = [] - wsgi_app = WsgiApplication(middleware) server_address=("0.0.0.0", int(config.get('port'))) @@ -116,6 +118,9 @@ def WebServer(debug = False): print "http://%s:%d/" % server_address return server +def mod_wsgi_application(sub_dir, config_dir , template_dir): + pass + def run(debug = False): server = WebServer(debug) try: diff --git a/deluge/ui/webui/lib/static_handler.py b/deluge/ui/webui/lib/static_handler.py index 5d02d0041..9b4a8c3e0 100644 --- a/deluge/ui/webui/lib/static_handler.py +++ b/deluge/ui/webui/lib/static_handler.py @@ -7,7 +7,7 @@ static fileserving for web.py without the need for wsgi wrapper magic. """ import web -from web import seeother, url +from web import url import posixpath import urlparse diff --git a/deluge/ui/webui/page_decorators.py b/deluge/ui/webui/page_decorators.py index 29eb252b9..a200a02aa 100644 --- a/deluge/ui/webui/page_decorators.py +++ b/deluge/ui/webui/page_decorators.py @@ -10,8 +10,9 @@ from deluge.log import LOG as log #/relative from web import cookies, setcookie as w_setcookie -from web import seeother, url -from web import changequery as self_url +from web import url, changequery +from utils import self_url +from render import error_page #deco's: def deluge_page_noauth(func): @@ -28,20 +29,32 @@ def deluge_page_noauth(func): def check_session(func): """ + 1:check session + 2:block urls in config.disallow return func if session is valid, else redirect to login page. mostly used for POST-pages. """ def deco(self, name = None): log.debug('%s.%s(name=%s)' % (self.__class__.__name__, func.__name__, name)) + #check disallow config + current_url = changequery() + for blocked in utils.config["disallow"]: + if current_url.startswith(blocked): + return error_page("Not allowed to : '%s' , Reason: '%s'" % + (blocked , utils.config["disallow"][blocked])) + #/check disallow + + #check session: vars = web.input(redir_after_login = None) ck = cookies() if ck.has_key("session_id") and ck["session_id"] in utils.SESSIONS: return func(self, name) #check_session:ok elif vars.redir_after_login: - seeother(url("/login",redir=self_url())) + utils.seeother(url("/login",redir=self_url())) else: - seeother("/login") #do not continue, and redirect to login page + utils.seeother("/login") #do not continue, and redirect to login page + #/check session deco.__name__ = func.__name__ return deco @@ -56,9 +69,7 @@ def check_connected(func): if connected: return func(self, name) #check_connected:ok else: - seeother("/connect") - - + utils.seeother("/connect") deco.__name__ = func.__name__ return deco @@ -122,3 +133,16 @@ def remote(func): print traceback.format_exc() deco.__name__ = func.__name__ return deco + +""" +obsolete: -> using check-session. +def check_allowed(capability): + def check_allowed_inner(func): + def deco(self, name = None): #check allowed (capablity) + if capability in config.get("disallow"): + return error_page("Not allowed to: '%s' , because:'%s'" + % (capability , config.get("disallow")[capability])) + return func(self, name) + return deco + return check_allowed_inner +""" \ No newline at end of file diff --git a/deluge/ui/webui/pages.py b/deluge/ui/webui/pages.py index 5e088f5c1..cd10eb1d1 100644 --- a/deluge/ui/webui/pages.py +++ b/deluge/ui/webui/pages.py @@ -43,7 +43,7 @@ from deluge.common import get_pixmap from deluge.log import LOG as log import web -from web import seeother, url +from web import url from lib.static_handler import static_handler from operator import attrgetter @@ -74,9 +74,10 @@ class login: start_session() do_redirect() elif vars.redir: - seeother(url('/login', error=1, redir=vars.redir)) + utils.seeother(url('/login', error=1, redir=vars.redir)) else: - seeother('/login?error=1') + utils.seeother('/login?error=1') + route('/login',login) class index: @@ -259,7 +260,7 @@ class logout: @deco.check_session def POST(self, name): end_session() - seeother('/login') + utils.seeother('/login') route('/logout', logout) class connect: @@ -304,7 +305,7 @@ class daemon_control: else: raise Exception('Unknown command:"%s"' % command) - seeother('/connect') + utils.seeother('/connect') def start(self): import time @@ -388,3 +389,13 @@ class pixmaps: web.header("Cache-Control" , "public, must-revalidate, max-age=86400") print content route("/pixmaps/(.*)", pixmaps) + +""" +#debug: +class catch_all: + @deco.deluge_page_noauth + def GET(self, name): + log.debug("xname=" + name) + print "name=" + name +route("(.*)", catch_all) +""" \ No newline at end of file diff --git a/deluge/ui/webui/render.py b/deluge/ui/webui/render.py index 36bc3ee66..733e2cca3 100644 --- a/deluge/ui/webui/render.py +++ b/deluge/ui/webui/render.py @@ -32,9 +32,10 @@ #relative: from webserver_common import REVNO, VERSION from utils import * +import utils #/relative from deluge import common -from web import changequery as self_url, template, Storage +from web import template, Storage import os from deluge.configmanager import ConfigManager @@ -56,14 +57,14 @@ class subclassed_render(object): self.webui_path = os.path.dirname(__file__) #load template-meta-data - cfg_template = config.get('template') - template_path = os.path.join(self.webui_path, 'templates/%s/' % cfg_template) + self.cfg_template = config.get('template') + template_path = os.path.join(self.webui_path, 'templates/%s/' % self.cfg_template) if not os.path.exists(template_path): template_path = os.path.join(self.webui_path, 'templates/deluge/') self.meta = Storage(eval(open(os.path.join(template_path,'meta.cfg')).read())) #load renerders - for template_name in [cfg_template] + list(reversed(self.meta.inherits)): + for template_name in [self.cfg_template] + list(reversed(self.meta.inherits)): self.renderers.append(template.render( os.path.join(self.webui_path, 'templates/%s/' % template_name),cache=False)) @@ -86,8 +87,7 @@ class subclassed_render(object): if hasattr(renderer, attr): self.template_cache[attr] = getattr(renderer, attr) return getattr(renderer, attr) - - raise AttributeError, 'no template named "%s" ' % attr + raise AttributeError, 'no template named "%s" in base path "%s"' % (attr, self.webui_path) def __getitem__(self, item): "for plugins/templates" @@ -102,6 +102,9 @@ class subclassed_render(object): if os.path.isdir(os.path.join(template_path, dirname)) and not dirname.startswith('.')] + @staticmethod + def set_global(key, val): + template.Template.globals[key] = val render = subclassed_render() @@ -186,7 +189,7 @@ template.Template.globals.update({ 'sorted': sorted, 'altrow':altrow, 'get_config': get_config, - 'self_url': self_url, + 'self_url': utils.self_url, 'fspeed': common.fspeed, 'fsize': common.fsize, 'ftime':ftime, @@ -195,10 +198,10 @@ template.Template.globals.update({ 'version': VERSION, 'getcookie':getcookie, 'get': lambda (var): getattr(web.input(**{var:None}), var), # unreadable :-( - 'env':'0.6', + #'env':'0.6', 'forms':web.Storage(), - 'enumerate':enumerate - + 'enumerate':enumerate, + 'base':'' #updated when running within apache. }) #/template-defs diff --git a/deluge/ui/webui/static/deluge.js b/deluge/ui/webui/static/deluge.js index da6be06e1..55ad88cd3 100644 --- a/deluge/ui/webui/static/deluge.js +++ b/deluge/ui/webui/static/deluge.js @@ -7,8 +7,9 @@ so i'd rather start from scratch, Probably broken in an unexpected way , but worksforme. */ state = { - 'row_js_continue':true - ,'selected_rows': new Array() + 'row_js_continue':true, + 'selected_rows': new Array(), + 'base_url':'' }; function $(el_id){ @@ -91,7 +92,7 @@ function open_details(e, id){ function open_inner_details(id){ /*probably broken for IE, use FF!*/ - $('torrent_info').src = '/torrent/info_inner/' + id; + $('torrent_info').src = state.base_url + '/torrent/info_inner/' + id; } function on_click_do_nothing(e, id){ diff --git a/deluge/ui/webui/templates/advanced/header.html b/deluge/ui/webui/templates/advanced/header.html index 0bab1d04b..4533bcbdb 100644 --- a/deluge/ui/webui/templates/advanced/header.html +++ b/deluge/ui/webui/templates/advanced/header.html @@ -2,10 +2,10 @@ $def with (title, active_tab=None) Deluge:$title - - - - + + + + @@ -13,7 +13,7 @@ $def with (title, active_tab=None)
- + \ No newline at end of file diff --git a/deluge/ui/webui/templates/advanced/part_stats.html b/deluge/ui/webui/templates/advanced/part_stats.html index 92ee49e4b..e72779947 100644 --- a/deluge/ui/webui/templates/advanced/part_stats.html +++ b/deluge/ui/webui/templates/advanced/part_stats.html @@ -2,20 +2,13 @@ $def with (stats)
- +$stats.num_connections ($deluge_int(stats.max_num_connections)) -$stats.num_connections ($deluge_int(stats.max_num_connections)) +$stats.download_rate ($deluge_int(stats.max_download)) -$stats.download_rate ($deluge_int(stats.max_download)) +$stats.upload_rate ($deluge_int(stats.max_upload)) -$stats.upload_rate ($deluge_int(stats.max_upload)) - -$stats.dht_nodes - - - - - +$stats.dht_nodes
diff --git a/deluge/ui/webui/templates/advanced/part_tb_button.html b/deluge/ui/webui/templates/advanced/part_tb_button.html index bc5ec9a21..6b7169dca 100644 --- a/deluge/ui/webui/templates/advanced/part_tb_button.html +++ b/deluge/ui/webui/templates/advanced/part_tb_button.html @@ -1,17 +1,17 @@ $def with (method, func, title, image='')
-
+ $if (get_config('button_style') == 0): $if (get_config('button_style') == 1): $if image: - + $else:
- \ No newline at end of file diff --git a/deluge/ui/webui/templates/advanced/part_toolbar.html b/deluge/ui/webui/templates/advanced/part_toolbar.html index 0399b2c39..2c8ff9cb2 100644 --- a/deluge/ui/webui/templates/advanced/part_toolbar.html +++ b/deluge/ui/webui/templates/advanced/part_toolbar.html @@ -1,6 +1,6 @@ $for id, title, image, flag, method, url, important in toolbar_items: $if important: + src='$base/static/images/tango/$image'> diff --git a/deluge/ui/webui/templates/advanced/part_torrent_list.html b/deluge/ui/webui/templates/advanced/part_torrent_list.html index df366c0e1..5226f493f 100644 --- a/deluge/ui/webui/templates/advanced/part_torrent_list.html +++ b/deluge/ui/webui/templates/advanced/part_torrent_list.html @@ -6,9 +6,11 @@ var all_torrents = [ $for t in torrent_list: "$t.id", ] +state.base_url = '$base'; + @@ -39,10 +41,10 @@ $#4-space indentation is mandatory for for-loops in templetor! $for torrent in torrent_list: diff --git a/deluge/ui/webui/templates/advanced/torrent_info_inner.html b/deluge/ui/webui/templates/advanced/torrent_info_inner.html index 3054e8508..a9bb622dc 100644 --- a/deluge/ui/webui/templates/advanced/torrent_info_inner.html +++ b/deluge/ui/webui/templates/advanced/torrent_info_inner.html @@ -3,7 +3,7 @@ $def with (torrent, active_tab) Deluge:$torrent.name - + diff --git a/deluge/ui/webui/templates/deluge/admin_toolbar.html b/deluge/ui/webui/templates/deluge/admin_toolbar.html index c46ad6af3..b2d1f732d 100644 --- a/deluge/ui/webui/templates/deluge/admin_toolbar.html +++ b/deluge/ui/webui/templates/deluge/admin_toolbar.html @@ -6,5 +6,5 @@ $for id, title, url in admin_pages: class="tab_button_active" $else: class="tab_button" - href='$url'>$title + href='$base$url'>$title diff --git a/deluge/ui/webui/templates/deluge/config.html b/deluge/ui/webui/templates/deluge/config.html index 8a4012c25..f58f2b4de 100644 --- a/deluge/ui/webui/templates/deluge/config.html +++ b/deluge/ui/webui/templates/deluge/config.html @@ -11,9 +11,9 @@ $for group in groups: $for page in pages: $if pages[page].group == group: $if page == selected: -
  • $pages[page].title
  • +
  • $pages[page].title
  • $else: -
  • $pages[page].title
  • +
  • $pages[page].title
  • diff --git a/deluge/ui/webui/templates/deluge/connect.html b/deluge/ui/webui/templates/deluge/connect.html index 8215a65dd..ca66b73b7 100644 --- a/deluge/ui/webui/templates/deluge/connect.html +++ b/deluge/ui/webui/templates/deluge/connect.html @@ -1,6 +1,6 @@ $def with (connect_list, connected) -$:render.header(_("Connect to Daemon"), 'Connect') +$:render.header(_("Connect to Daemon"), 'connect') $:render.admin_toolbar('connect') @@ -12,12 +12,12 @@ $if connected: $_('Connected to') $connected diff --git a/deluge/ui/webui/templates/deluge/tab_files.html b/deluge/ui/webui/templates/deluge/tab_files.html index 9d62e9513..4f9950649 100644 --- a/deluge/ui/webui/templates/deluge/tab_files.html +++ b/deluge/ui/webui/templates/deluge/tab_files.html @@ -1,6 +1,6 @@ $def with (torrent) - +
    -
    -
    +
    -
    +
    @@ -25,7 +25,7 @@ $if connected: $else:
    $_("Not Connected to a daemon")
    -
    + diff --git a/deluge/ui/webui/templates/deluge/header.html b/deluge/ui/webui/templates/deluge/header.html index 3b0b7e8a5..eff4c8dd5 100644 --- a/deluge/ui/webui/templates/deluge/header.html +++ b/deluge/ui/webui/templates/deluge/header.html @@ -2,16 +2,16 @@ $def with (title, active_tab="NONE") Deluge:$title - - - + + +
    - + $torrent.queue - + $(crop(torrent.name, 40)) $fsize(torrent.total_size) diff --git a/deluge/ui/webui/templates/deluge/login.html b/deluge/ui/webui/templates/deluge/login.html index 0e5b24dfa..969b5e495 100644 --- a/deluge/ui/webui/templates/deluge/login.html +++ b/deluge/ui/webui/templates/deluge/login.html @@ -6,7 +6,7 @@ $:render.header(_('Login')) $if error > 0:
    $_("Password is invalid,try again")
    -
    +
    diff --git a/deluge/ui/webui/templates/deluge/part_button.html b/deluge/ui/webui/templates/deluge/part_button.html index 2dc23e65a..9acdf5afd 100644 --- a/deluge/ui/webui/templates/deluge/part_button.html +++ b/deluge/ui/webui/templates/deluge/part_button.html @@ -1,17 +1,17 @@ $def with (method, url, title, image='')
    - + $if (int(get_config('button_style')) == 0): $if (int(get_config('button_style')) == 1): $if image: - + $else:
    - $_('Connections') : $stats.num_connections ($stats.max_num_connections) @@ -26,14 +25,8 @@ $:render.part_button('POST', '/logout', _('Logout'), 'tango/system-log-out.png') $_('Up Speed') : $stats.upload_rate ($stats.max_upload) - - - -$if env == '0.6': $:render.part_button('GET', '/config/', _('Settings'), 'tango/preferences-system.png') - -
    diff --git a/deluge/ui/webui/templates/deluge/refresh_form.html b/deluge/ui/webui/templates/deluge/refresh_form.html index 0ac2cffda..42c2d2c6f 100644 --- a/deluge/ui/webui/templates/deluge/refresh_form.html +++ b/deluge/ui/webui/templates/deluge/refresh_form.html @@ -1,6 +1,6 @@ $:render.header(_('Set Timeout'))
    - + $_('Refresh page every:') diff --git a/deluge/ui/webui/templates/deluge/sort_column_head.html b/deluge/ui/webui/templates/deluge/sort_column_head.html index 6712cb9b9..4d7ea981b 100644 --- a/deluge/ui/webui/templates/deluge/sort_column_head.html +++ b/deluge/ui/webui/templates/deluge/sort_column_head.html @@ -1,11 +1,11 @@ $def with (column_id, column_name, order, active_up, active_down)
    - + $column_name\ $if active_up: - + $if active_down: - +
    diff --git a/deluge/ui/webui/templates/deluge/tab_options.html b/deluge/ui/webui/templates/deluge/tab_options.html index 23b73ba09..5ea736fdf 100644 --- a/deluge/ui/webui/templates/deluge/tab_options.html +++ b/deluge/ui/webui/templates/deluge/tab_options.html @@ -1,5 +1,5 @@ $def with (torrent) - +
    diff --git a/deluge/ui/webui/templates/deluge/tab_peers.html b/deluge/ui/webui/templates/deluge/tab_peers.html index 4374ae589..ee29f261a 100644 --- a/deluge/ui/webui/templates/deluge/tab_peers.html +++ b/deluge/ui/webui/templates/deluge/tab_peers.html @@ -1,6 +1,6 @@ $def with (torrent) - +
    diff --git a/deluge/ui/webui/templates/deluge/torrent_add.html b/deluge/ui/webui/templates/deluge/torrent_add.html index f9d999c02..82a988227 100644 --- a/deluge/ui/webui/templates/deluge/torrent_add.html +++ b/deluge/ui/webui/templates/deluge/torrent_add.html @@ -2,7 +2,7 @@ $def with (add_form, options_form, error) $:render.header(_("Add Torrent"))

    $_("Add Torrent")

    - + diff --git a/deluge/ui/webui/templates/deluge/torrent_delete.html b/deluge/ui/webui/templates/deluge/torrent_delete.html index a9aceb551..46b37701d 100644 --- a/deluge/ui/webui/templates/deluge/torrent_delete.html +++ b/deluge/ui/webui/templates/deluge/torrent_delete.html @@ -1,7 +1,7 @@ $def with (torrent_ids, torrent_list) $:render.header(_("Remove torrent"))
    - +

    $_("Remove torrent")

    diff --git a/deluge/ui/webui/templates/deluge/torrent_move.html b/deluge/ui/webui/templates/deluge/torrent_move.html index d240dbe5e..395c2adf6 100644 --- a/deluge/ui/webui/templates/deluge/torrent_move.html +++ b/deluge/ui/webui/templates/deluge/torrent_move.html @@ -1,7 +1,7 @@ $def with (torrent_ids, torrent_list, form, error) $:render.header(_("Remove torrent"))
    - +

    $_("Move torrent")

      diff --git a/deluge/ui/webui/templates/white/header.html b/deluge/ui/webui/templates/white/header.html index 7fc35594e..4d7840da8 100644 --- a/deluge/ui/webui/templates/white/header.html +++ b/deluge/ui/webui/templates/white/header.html @@ -4,10 +4,10 @@ $def with (title, active_tab="NONE") Deluge:$_('Torrent list') - - - - + + + + @@ -22,7 +22,7 @@ $def with (title, active_tab="NONE") class="tab_button_active" $else: class="tab_button" - href='/home'>Home + href='$base/home'>Home $for id, title, url in admin_pages: @@ -31,7 +31,7 @@ $for id, title, url in admin_pages: class="tab_button_active" $else: class="tab_button" - href='$url'>$title + href='$base$url'>$title
    diff --git a/deluge/ui/webui/templates/white/index.html b/deluge/ui/webui/templates/white/index.html index fd5434a52..acac8e528 100644 --- a/deluge/ui/webui/templates/white/index.html +++ b/deluge/ui/webui/templates/white/index.html @@ -4,10 +4,10 @@ $def with (torrent_list, organize_filters) Deluge:$_('Torrent list') - - - - + + + + @@ -16,9 +16,9 @@ $def with (torrent_list, organize_filters)
    - Home + Home $for id, title, url in admin_pages: - $title + $title
    @@ -30,8 +30,6 @@ $def with (torrent_list, organize_filters)
    - - $if organize_filters: $:render.part_organize(organize_filters) diff --git a/deluge/ui/webui/templates/white/part_organize.html b/deluge/ui/webui/templates/white/part_organize.html index 7be24a8b0..22a96334a 100644 --- a/deluge/ui/webui/templates/white/part_organize.html +++ b/deluge/ui/webui/templates/white/part_organize.html @@ -13,7 +13,7 @@ $for state, num in filters.state: $if state == get('state'): class="selected" > - + $_(state) ($num) $else: @@ -49,9 +49,6 @@ $if get('keyword'): - diff --git a/deluge/ui/webui/utils.py b/deluge/ui/webui/utils.py index 33fb0175d..a2be06210 100644 --- a/deluge/ui/webui/utils.py +++ b/deluge/ui/webui/utils.py @@ -30,16 +30,7 @@ # this exception statement from your version. If you delete this exception # statement from all source files in the program, then also delete it here. -import web import os -from web import cookies, setcookie as w_setcookie -from web import changequery as self_url, template -from web import Storage -from web import seeother, url - -from deluge.common import fsize,fspeed,ftime -from deluge.log import LOG as log - import traceback import random from operator import attrgetter @@ -48,14 +39,19 @@ import pickle from urlparse import urlparse from md5 import md5 -from webserver_common import REVNO, VERSION, TORRENT_KEYS, STATE_MESSAGES, CONFIG_DEFAULTS -from deluge.ui.client import sclient as proxy -from deluge.ui.client import aclient as async_proxy - +import web +from web import changequery , template , url , Storage +from web import cookies, setcookie as w_setcookie +from web import seeother as w_seeother +from deluge.common import fsize, fspeed, ftime from deluge import component +from deluge.log import LOG as log from deluge.configmanager import ConfigManager +from webserver_common import REVNO, VERSION, TORRENT_KEYS, CONFIG_DEFAULTS +from deluge.ui.client import sclient, aclient + webui_plugin_manager = component.get("WebPluginManager") config = ConfigManager("webui.conf") @@ -70,7 +66,6 @@ def setcookie(key, val): """add 30 days expires header for persistent cookies""" return w_setcookie(key, val , expires=2592000) - #really simple sessions, to bad i had to implement them myself. SESSIONS = [] def start_session(): @@ -83,6 +78,14 @@ def end_session(): setcookie("session_id","") #/sessions +def seeother(url, *args, **kwargs): + url_with_base = config["base"] + url + log.debug("seeother:%s" % url_with_base) + return w_seeother(url_with_base, *args, **kwargs) + +def self_url(**kwargs): + return config["base"] + changequery(**kwargs) + def do_redirect(): """for redirects after a POST""" vars = web.input(redir = None) @@ -91,7 +94,7 @@ def do_redirect(): #redirect to a non-default page. if vars.redir: - seeother(vars.redir) + w_seeother(vars.redir) #redir variable contains base return #for the filters: @@ -100,7 +103,7 @@ def do_redirect(): organize = False try: - organize = ('Organize' in proxy.get_enabled_plugins()) + organize = ('Organize' in sclient.get_enabled_plugins()) except: pass @@ -114,7 +117,7 @@ def do_redirect(): url_vars['keyword'] = ck['keyword'] #redirect. - seeother(url("/index", **url_vars)) + w_seeother(url("/index", **url_vars)) def getcookie(key, default = None): "because i'm too lazy to type 3 lines for something this simple" @@ -125,18 +128,18 @@ def getcookie(key, default = None): def get_stats(): stats = Storage() - async_proxy.get_download_rate(dict_cb('download_rate',stats)) - async_proxy.get_upload_rate(dict_cb('upload_rate',stats)) - async_proxy.get_config_value(dict_cb('max_download',stats) + aclient.get_download_rate(dict_cb('download_rate',stats)) + aclient.get_upload_rate(dict_cb('upload_rate',stats)) + aclient.get_config_value(dict_cb('max_download',stats) ,"max_download_speed") - async_proxy.get_config_value(dict_cb('max_upload',stats) + aclient.get_config_value(dict_cb('max_upload',stats) ,"max_upload_speed") - async_proxy.get_num_connections(dict_cb("num_connections",stats)) - async_proxy.get_config_value(dict_cb('max_num_connections',stats) + aclient.get_num_connections(dict_cb("num_connections",stats)) + aclient.get_config_value(dict_cb('max_num_connections',stats) ,"max_connections_global") - async_proxy.get_dht_nodes(dict_cb('dht_nodes',stats)) + aclient.get_dht_nodes(dict_cb('dht_nodes',stats)) - async_proxy.force_call(block=True) + aclient.force_call(block=True) stats.download_rate = fspeed(stats.download_rate) stats.upload_rate = fspeed(stats.upload_rate) @@ -177,16 +180,16 @@ def enhance_torrent_status(torrent_id,status): def get_torrent_status(torrent_id): """ helper method. - enhance proxy.get_torrent_status with some extra data + enhance sclient.get_torrent_status with some extra data """ - status = proxy.get_torrent_status(torrent_id,TORRENT_KEYS) + status = sclient.get_torrent_status(torrent_id,TORRENT_KEYS) return enhance_torrent_status(torrent_id, status) def get_enhanced_torrent_list(torrent_ids): """ returns a list of storified-torrent-dicts. """ - torrent_dict = proxy.get_torrents_status(torrent_ids, TORRENT_KEYS) + torrent_dict = sclient.get_torrents_status(torrent_ids, TORRENT_KEYS) return [enhance_torrent_status(id, status) for id, status in torrent_dict.iteritems()] @@ -239,7 +242,7 @@ def daemon_connect(uri): config.set('daemon', uri) config.save() - proxy.set_core_uri(uri) + sclient.set_core_uri(uri) webui_plugin_manager.start() #generic: @@ -279,8 +282,12 @@ def set_config_defaults(): if changed: config.save() - - +def apply_config(): + #etc, mostly for apache: + from render import render + sclient.set_core_uri(config.get('daemon')) + render.set_global('base', config.get('base')) + render.apply_cfg() #exceptions: class WebUiError(Exception): @@ -290,3 +297,4 @@ class WebUiError(Exception): class UnknownTorrentError(WebUiError): pass + diff --git a/deluge/ui/webui/webserver_common.py b/deluge/ui/webui/webserver_common.py index 66e4b88d5..5a9555d99 100644 --- a/deluge/ui/webui/webserver_common.py +++ b/deluge/ui/webui/webserver_common.py @@ -32,10 +32,8 @@ """ webui constants """ - import os -#constants try: REVNO = open(os.path.join(os.path.dirname(__file__),'revno')).read() except: @@ -59,16 +57,6 @@ TORRENT_KEYS = ['name', 'total_size', 'num_files', 'num_pieces', 'piece_length', 'tracker_name' #organize-plugin ] -STATE_MESSAGES = [ - "Allocating", - "Checking", - "Downloading", - "Seeding", - "Paused", - "Error" - ] - - CONFIG_DEFAULTS = { "port":8112, "button_style":2, @@ -79,9 +67,7 @@ CONFIG_DEFAULTS = { "pwd_md5":".\xe8w\\+\xec\xdb\xf2id4F\xdb\rUc", "cache_templates":True, "use_https":False, - "daemon":"http://localhost:58846" + "daemon":"http://localhost:58846", + "base":"", + "disallow":{} } - -#/constants - -