config fixes
This commit is contained in:
parent
41dbab69b2
commit
a311bcbcec
|
@ -541,7 +541,7 @@ class Core(
|
|||
|
||||
def export_set_config(self, config):
|
||||
"""Set the config with values from dictionary"""
|
||||
config = deluge.common.pythonize(config)
|
||||
#config = deluge.common.pythonize(config)
|
||||
# Load all the values into the configuration
|
||||
for key in config.keys():
|
||||
if isinstance(config[key], unicode) or isinstance(config[key], str):
|
||||
|
|
|
@ -108,7 +108,7 @@ class Core(CorePluginBase):
|
|||
|
||||
def export_get_config(self):
|
||||
"""Returns the config dictionary"""
|
||||
return self.config.get_config()
|
||||
return self.config.config
|
||||
|
||||
def export_set_config(self, config):
|
||||
"""Sets the config based on values in 'config'"""
|
||||
|
|
|
@ -8,10 +8,6 @@ popup_icon = "/static/images/tango/emblem-symbolic-link.png" /*the best i could
|
|||
|
||||
Plugins = {}
|
||||
|
||||
function _(str) {
|
||||
return str /*#todo : translations; see Deluge.Strings.get*/
|
||||
}
|
||||
|
||||
Plugins.Label = {
|
||||
/*onload:*/
|
||||
initialize: function() {
|
||||
|
|
|
@ -153,4 +153,4 @@ class Core(CorePluginBase):
|
|||
|
||||
def export_get_config(self):
|
||||
"returns the config dictionary"
|
||||
return self.config.get_config()
|
||||
return self.config.config
|
||||
|
|
|
@ -119,7 +119,7 @@ class Core(CorePluginBase):
|
|||
|
||||
def export_get_config(self):
|
||||
"returns the config dictionary"
|
||||
return self.config.get_config()
|
||||
return self.config.config
|
||||
"""
|
||||
|
||||
INIT = """
|
||||
|
|
|
@ -24,11 +24,11 @@ def get_wsgi_application(base_url, config_dir):
|
|||
|
||||
utils.set_config_defaults()
|
||||
|
||||
config.set('base','/deluge')
|
||||
config.set('disallow',{
|
||||
config['base'] = '/deluge'
|
||||
config['disallow'] = {
|
||||
'/daemon/control':'running as an apache user',
|
||||
'/config/server':'running as an apache-user'
|
||||
})
|
||||
}
|
||||
|
||||
utils.apply_config()
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ config_page_manager = component.get("ConfigPageManager")
|
|||
class WebCfgForm(forms.Form):
|
||||
"config base for webui"
|
||||
def initial_data(self):
|
||||
return config.get_config()
|
||||
return config.config
|
||||
|
||||
def save(self, data):
|
||||
utils.validate_config(data)
|
||||
|
|
|
@ -37,7 +37,9 @@ import pkg_resources
|
|||
from deluge.ui.client import sclient
|
||||
import components
|
||||
from deluge.log import LOG as log
|
||||
from webserver_common import CONFIG_DEFAULTS
|
||||
|
||||
config = ConfigManager("webui06.conf", CONFIG_DEFAULTS)
|
||||
|
||||
# Initialize gettext
|
||||
if deluge.common.windows_check() or deluge.common.osx_check():
|
||||
|
@ -65,7 +67,6 @@ import utils
|
|||
|
||||
|
||||
## Init ##
|
||||
config = ConfigManager("webui06.conf")
|
||||
random.seed()
|
||||
web.webapi.internalerror = deluge_debugerror
|
||||
|
||||
|
@ -104,10 +105,10 @@ def create_webserver(debug = False, base_url =None):
|
|||
|
||||
utils.set_config_defaults()
|
||||
if base_url:
|
||||
config.set('base', base_url)
|
||||
config['base'] = base_url
|
||||
else:
|
||||
config.set('base','')
|
||||
config.set('disallow',{})
|
||||
config['base'] = ''
|
||||
config['disallow'] = {}
|
||||
utils.apply_config()
|
||||
|
||||
|
||||
|
@ -119,11 +120,11 @@ def create_webserver(debug = False, base_url =None):
|
|||
|
||||
wsgi_app = WsgiApplication(middleware)
|
||||
|
||||
server_address=("0.0.0.0", int(config.get('port')))
|
||||
server_address=("0.0.0.0", int(config['port']))
|
||||
server = CherryPyWSGIServer(server_address, wsgi_app, server_name="localhost")
|
||||
|
||||
https = False
|
||||
if config.get("https"):
|
||||
if config["https"]:
|
||||
import os
|
||||
from deluge.common import get_default_config_dir
|
||||
cert_path = os.path.join(get_default_config_dir("ssl") ,"deluge.cert.pem" )
|
||||
|
|
|
@ -98,7 +98,7 @@ class json_rpc:
|
|||
web.header("Content-Type", "application/x-json")
|
||||
ck = cookies()
|
||||
id = 0
|
||||
if not(ck.has_key("session_id") and ck["session_id"] in utils.config.get("sessions")):
|
||||
if not(ck.has_key("session_id") and ck["session_id"] in utils.config["sessions"]):
|
||||
return json_error("not authenticated", id)
|
||||
|
||||
try:
|
||||
|
@ -172,7 +172,7 @@ class json_rpc:
|
|||
}
|
||||
|
||||
def get_webui_config(self):
|
||||
return dict([x for x in utils.config.get_config().iteritems() if not x[0].startswith("pwd")])
|
||||
return dict([x for x in utils.config.config().iteritems() if not x[0].startswith("pwd")])
|
||||
|
||||
def set_webui_config(self, data):
|
||||
utils.validate_config(data)
|
||||
|
|
|
@ -49,7 +49,7 @@ def check_session(func):
|
|||
#check session:
|
||||
vars = web.input(redir_after_login = None)
|
||||
ck = cookies()
|
||||
if ck.has_key("session_id") and ck["session_id"] in utils.config.get("sessions"):
|
||||
if ck.has_key("session_id") and ck["session_id"] in utils.config["sessions"]:
|
||||
return func(self, name) #check_session:ok
|
||||
elif vars.redir_after_login:
|
||||
utils.seeother(url("/login",redir=self_url()))
|
||||
|
@ -135,16 +135,3 @@ 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
|
||||
"""
|
|
@ -310,8 +310,8 @@ class connect:
|
|||
connected = None
|
||||
|
||||
connect_list = ["http://localhost:58846"]
|
||||
if config.get('daemon') <> "http://localhost:58846":
|
||||
connect_list = [config.get('daemon')] + connect_list
|
||||
if config['daemon'] <> "http://localhost:58846":
|
||||
connect_list = [config['daemon']] + connect_list
|
||||
|
||||
return render.connect(connect_list, connected ,restart)
|
||||
|
||||
|
@ -390,7 +390,7 @@ route("/static/(.*)", static)
|
|||
class template_static(static_handler):
|
||||
def get_base_dir(self):
|
||||
return os.path.join(os.path.dirname(__file__),
|
||||
'templates/%s/static' % config.get('template'))
|
||||
'templates/%s/static' % config['template'])
|
||||
route("/template/static/(.*)", template_static)
|
||||
|
||||
class template_render:
|
||||
|
@ -398,9 +398,9 @@ class template_render:
|
|||
|
||||
def GET(self, name):
|
||||
web.header("Content-type",utils.guess_mime_type(name))
|
||||
#security : assumes config.get('template') returns a safe subdir.
|
||||
#security : assumes config['template'] returns a safe subdir.
|
||||
basepath = os.path.normpath(os.path.join(os.path.dirname(__file__),
|
||||
'templates/%s/render' % config.get('template')))
|
||||
'templates/%s/render' % config['template']))
|
||||
filename = os.path.normpath(os.path.join(basepath,name))
|
||||
if not filename.startswith(basepath):
|
||||
#hack detected?
|
||||
|
|
|
@ -54,13 +54,13 @@ class subclassed_render(object):
|
|||
self.plugin_renderers = []
|
||||
|
||||
def apply_cfg(self):
|
||||
self.cache = config.get('cache_templates')
|
||||
self.cache = config['cache_templates']
|
||||
self.renderers = []
|
||||
self.template_cache = {}
|
||||
self.webui_path = os.path.dirname(__file__)
|
||||
|
||||
#load template-meta-data
|
||||
self.cfg_template = config.get('template')
|
||||
self.cfg_template = config['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/white/')
|
||||
|
@ -155,7 +155,7 @@ def template_part_stats():
|
|||
return '[not connected]'
|
||||
|
||||
def get_config(var):
|
||||
return config.get(var)
|
||||
return config[var]
|
||||
|
||||
irow = 0
|
||||
def altrow(reset = False):
|
||||
|
|
|
@ -54,7 +54,7 @@ from webserver_common import TORRENT_KEYS, CONFIG_DEFAULTS
|
|||
from deluge.ui.client import sclient, aclient
|
||||
|
||||
webui_plugin_manager = component.get("WebPluginManager")
|
||||
config = ConfigManager("webui06.conf")
|
||||
config = ConfigManager("webui06.conf", CONFIG_DEFAULTS)
|
||||
|
||||
#async-proxy: map callback to a a dict-setter
|
||||
def dict_cb(key,d):
|
||||
|
@ -70,18 +70,18 @@ def setcookie(key, val):
|
|||
#really simple sessions, to bad i had to implement them myself.
|
||||
def start_session():
|
||||
session_id = str(random.random())
|
||||
config.set("sessions", config.get("sessions") + [session_id])
|
||||
if len(config.get("sessions")) > 30: #store a max of 20 sessions.
|
||||
config.set("sessions",config["sessions"][:-20])
|
||||
config["sessions"] = config["sessions"] + [session_id]
|
||||
if len(config["sessions"]) > 30: #store a max of 20 sessions.
|
||||
config["sessions"] = config["sessions"][:-20]
|
||||
setcookie("session_id", session_id)
|
||||
config.save()
|
||||
|
||||
def end_session():
|
||||
session_id = getcookie("session_id")
|
||||
setcookie("session_id","")
|
||||
if session_id in config.get("sessions"):
|
||||
if session_id in config["sessions"]:
|
||||
config["sessions"].remove(session_id)
|
||||
config.set("sessions", config["sessions"])
|
||||
config["sessions"] = config["sessions"]
|
||||
#/sessions
|
||||
|
||||
def seeother(url, *args, **kwargs):
|
||||
|
@ -206,8 +206,8 @@ def daemon_start_localhost(port):
|
|||
subprocess.Popen(["deluged", "-p %s" % port])
|
||||
|
||||
def daemon_connect(uri):
|
||||
if config.get('daemon') <> uri:
|
||||
config.set('daemon', uri)
|
||||
if config['daemon'] <> uri:
|
||||
config['daemon'] = uri
|
||||
config.save()
|
||||
|
||||
sclient.set_core_uri(uri)
|
||||
|
@ -231,15 +231,15 @@ def update_pwd(pwd):
|
|||
m.update(salt)
|
||||
m.update(pwd)
|
||||
#
|
||||
config.set("pwd_salt", salt)
|
||||
config.set("pwd_md5", m.digest())
|
||||
config["pwd_salt"] = salt
|
||||
config["pwd_md5"] = m.digest()
|
||||
config.save()
|
||||
|
||||
def check_pwd(pwd):
|
||||
m = md5()
|
||||
m.update(config.get('pwd_salt'))
|
||||
m.update(config['pwd_salt'])
|
||||
m.update(pwd)
|
||||
return (m.digest() == config.get('pwd_md5'))
|
||||
return (m.digest() == config['pwd_md5'])
|
||||
|
||||
def validate_config(cfg_dict):
|
||||
"""
|
||||
|
@ -254,6 +254,9 @@ def validate_config(cfg_dict):
|
|||
|
||||
|
||||
def set_config_defaults():
|
||||
"""
|
||||
OBSOLETE, TODO REMOVE THIS !!
|
||||
"""
|
||||
changed = False
|
||||
for key, value in CONFIG_DEFAULTS.iteritems():
|
||||
if not key in config.config:
|
||||
|
@ -261,8 +264,8 @@ def set_config_defaults():
|
|||
changed = True
|
||||
|
||||
from render import render
|
||||
if not config.get("template") in render.get_templates():
|
||||
config.set("template", CONFIG_DEFAULTS["template"])
|
||||
if not config["template"] in render.get_templates():
|
||||
config["template"] = CONFIG_DEFAULTS["template"]
|
||||
changed = True
|
||||
|
||||
if changed:
|
||||
|
@ -272,11 +275,10 @@ def apply_config():
|
|||
#etc, mostly for apache:
|
||||
from render import render
|
||||
try:
|
||||
#sclient.set_core_uri(config.get('daemon'))
|
||||
daemon_connect(config.get('daemon'))
|
||||
daemon_connect(config['daemon'])
|
||||
except Exception,e:
|
||||
log.debug("error setting core uri:%s:%s:%s" % (config.get('daemon'),e,e.message))
|
||||
render.set_global('base', config.get('base'))
|
||||
log.debug("error setting core uri:%s:%s:%s" % (config['daemon'], e, e.message))
|
||||
render.set_global('base', config['base'])
|
||||
render.apply_cfg()
|
||||
|
||||
#exceptions:
|
||||
|
|
|
@ -904,6 +904,9 @@ void upnp::on_upnp_xml(error_code const& e
|
|||
if (s.url_base.empty()) d.control_url = s.control_url;
|
||||
else d.control_url = s.url_base + s.control_url;
|
||||
|
||||
if (s.url_base.empty()) d.control_url = s.control_url;
|
||||
else d.control_url = s.url_base + s.control_url;
|
||||
|
||||
std::string protocol;
|
||||
std::string auth;
|
||||
char const* error;
|
||||
|
|
Loading…
Reference in New Issue