diff --git a/deluge/ui/webui/webui_plugin/__init__.py b/deluge/ui/webui/webui_plugin/__init__.py index 1807ac222..5ccb24fe6 100644 --- a/deluge/ui/webui/webui_plugin/__init__.py +++ b/deluge/ui/webui/webui_plugin/__init__.py @@ -46,11 +46,13 @@ Other contributors: *markybob : stability : synced with his changes in deluge-svn. """ + import deluge.common +from webserver_common import ws,REVNO,VERSION + try: import deluge.pref from deluge.dialogs import show_popup_warning - from webserver_common import ws except ImportError: print 'WebUi:not imported as a plugin' @@ -72,15 +74,8 @@ from threading import Thread import random random.seed() -try: - plugin_version += open(os.path.join(os.path.dirname(__file__),'revno')).read() -except: - plugin_version = "No Version" -try: - plugin_description += ( - open(os.path.join(os.path.dirname(__file__),'version')).read()) -except: - plugin_description = "No Version" +plugin_version += REVNO +plugin_description += VERSION def deluge_init(deluge_path): global path diff --git a/deluge/ui/webui/webui_plugin/pages.py b/deluge/ui/webui/webui_plugin/pages.py index 5e35a40fc..e62d1055f 100644 --- a/deluge/ui/webui/webui_plugin/pages.py +++ b/deluge/ui/webui/webui_plugin/pages.py @@ -35,6 +35,7 @@ from webserver_common import ws from utils import * from render import render, error_page import page_decorators as deco +import forms import lib.webpy022 as web from lib.webpy022.http import seeother, url @@ -63,7 +64,7 @@ urls = ( "/resume_all", "resume_all", "/refresh/set", "refresh_set", "/refresh/(.*)", "refresh", - "/config", "config_", + "/config", "config", "/home", "home", "/about", "about", "/logout", "logout", @@ -304,33 +305,20 @@ class refresh_set: else: error_page(_('refresh must be > 0')) -class config_: #namespace clash? +class config: #namespace clash? """core config TODO:good validation. """ - """ - SOMEHOW ONLY BREAKS 0.6 ?? - cfg_form = web.form.Form( - web.form.Dropdown('max_download',SPEED_VALUES, - description=_('Download Speed Limit'), - post='%s Kib/sec' % ws.proxy.get_config_value('max_download_speed') - ) - ,web.form.Dropdown('max_upload', ws.SPEED_VALUES, - description=_('Upload Speed Limit'), - post='%s Kib/sec' % ws.proxy.get_config_value('max_upload_speed') - ) - ) - @deco.deluge_page def GET(self, name): - return render.config(self.cfg_form()) + return render.config(forms.bandwith()) - def POST(self, name): + def POST(self): vars = web.input(max_download=None, max_upload=None) #self.config.set("max_download_speed", float(str_bwdown)) raise NotImplementedError('todo') - """ + class home: @deco.check_session diff --git a/deluge/ui/webui/webui_plugin/render.py b/deluge/ui/webui/webui_plugin/render.py index 0a0f97bd1..b42ff3571 100644 --- a/deluge/ui/webui/webui_plugin/render.py +++ b/deluge/ui/webui/webui_plugin/render.py @@ -44,13 +44,17 @@ class subclassed_render(object): try to use the html template in configured dir. not available : use template in /deluge/ """ - def __init__(self, template_dirname, cache=False): + def __init__(self): + self.apply_cfg() + + def apply_cfg(self): + cache = ws.config.get('cache_templates') self.base_template = template.render( os.path.join(ws.webui_path, 'templates/deluge/'), cache=cache) self.sub_template = template.render( - os.path.join(ws.webui_path, 'templates/%s/' % template_dirname), + os.path.join(ws.webui_path, 'templates/%s/' % ws.config.get('template')), cache=cache) def __getattr__(self, attr): @@ -59,9 +63,7 @@ class subclassed_render(object): else: return getattr(self.base_template, attr) -render = subclassed_render( - ws.config.get('template'), - ws.config.get('cache_templates')) +render = subclassed_render() def error_page(error): web.header("Content-Type", "text/html; charset=utf-8") diff --git a/deluge/ui/webui/webui_plugin/webserver_common.py b/deluge/ui/webui/webui_plugin/webserver_common.py index 7b418ce29..c1aa93294 100644 --- a/deluge/ui/webui/webui_plugin/webserver_common.py +++ b/deluge/ui/webui/webui_plugin/webserver_common.py @@ -166,7 +166,7 @@ class Ws: self.log.debug('cfg-file %s' % self.config_file) if not os.path.exists(self.config_file): - self.log.debug('create cfg file %s' % config_file) + self.log.debug('create cfg file %s' % self.config_file) #load&save defaults. f = file(self.config_file,'wb') pickle.dump(CONFIG_DEFAULTS,f) @@ -192,7 +192,7 @@ class Ws: #other bug: must warn if blocklist plugin is active! from dbus_interface import get_dbus_manager self.proxy = get_dbus_manager() - self.config = deluge.pref.Preferences(config_file, False) + self.config = deluge.pref.Preferences(self.config_file, False) self.env = '0.5_gtk' self.init_logger()