From a28e33b8090fa25bb09ac3e713e89a8af5276b91 Mon Sep 17 00:00:00 2001 From: Marcos Pinto Date: Tue, 23 Oct 2007 22:16:37 +0000 Subject: [PATCH] sync with webui rev87 --- plugins/WebUi/deluge_webserver.py | 1 - plugins/WebUi/revno | 2 +- plugins/WebUi/version | 6 +++--- plugins/WebUi/webserver_common.py | 2 +- plugins/WebUi/webserver_framework.py | 21 +++++++++++++++------ 5 files changed, 20 insertions(+), 12 deletions(-) diff --git a/plugins/WebUi/deluge_webserver.py b/plugins/WebUi/deluge_webserver.py index c081c73bc..a39200683 100644 --- a/plugins/WebUi/deluge_webserver.py +++ b/plugins/WebUi/deluge_webserver.py @@ -39,7 +39,6 @@ from webserver_framework import * import webpy022 as web from webpy022.http import seeother, url -from webpy022.webapi import setcookie from webpy022.utils import Storage from md5 import md5 diff --git a/plugins/WebUi/revno b/plugins/WebUi/revno index e1617e842..84df3526d 100644 --- a/plugins/WebUi/revno +++ b/plugins/WebUi/revno @@ -1 +1 @@ -57 +87 diff --git a/plugins/WebUi/version b/plugins/WebUi/version index a81f14b5b..448878e1e 100644 --- a/plugins/WebUi/version +++ b/plugins/WebUi/version @@ -1,5 +1,5 @@ revision-id: mvoncken@gmail.com-20070930083408-sv8mo0mi1rbjnfvk -date: 2007-09-30 10:34:08 +0200 -build-date: 2007-09-30 10:34:50 +0200 -revno: 57 +date: 2007-10-23 15:10:08 +0200 +build-date: 2007-10-23 15:34:50 +0200 +revno: 87 branch-nick: WebUi diff --git a/plugins/WebUi/webserver_common.py b/plugins/WebUi/webserver_common.py index 1b1aefa62..2173f7712 100644 --- a/plugins/WebUi/webserver_common.py +++ b/plugins/WebUi/webserver_common.py @@ -62,7 +62,7 @@ def init(): -REVNO = open(os.path.join(os.path.dirname(__file__),'revno')).read() +REVNO = '0.56.stable.' + open(os.path.join(os.path.dirname(__file__),'revno')).read() VERSION = open(os.path.join(os.path.dirname(__file__),'version')).read() TORRENT_KEYS = ['distributed_copies', 'download_payload_rate', diff --git a/plugins/WebUi/webserver_framework.py b/plugins/WebUi/webserver_framework.py index b8163b38f..b7254886b 100644 --- a/plugins/WebUi/webserver_framework.py +++ b/plugins/WebUi/webserver_framework.py @@ -42,7 +42,7 @@ Todo's before stable: """ import webpy022 as web -from webpy022.webapi import cookies, setcookie +from webpy022.webapi import cookies, setcookie as w_setcookie from webpy022.http import seeother, url from webpy022 import template,changequery as self_url @@ -54,13 +54,17 @@ from deluge import common from webserver_common import REVNO, VERSION import webserver_common as ws +from debugerror import deluge_debugerror + #init: -web.webapi.internalerror = web.debugerror - - +web.webapi.internalerror = deluge_debugerror #/init #methods: +def setcookie(key, val): + """add 30 days expires header for persistent cookies""" + return w_setcookie(key, val , expires=2592000) + SESSIONS = [] #dumb sessions. def start_session(): session_id = str(random.random()) @@ -88,8 +92,13 @@ def error_page(error): print ws.render.error(error) def getcookie(key, default=None): + COOKIE_DEFAULTS = {'auto_refresh_secs':'10'} + key = str(key).strip() ck = cookies() - return str(ck.get(key, default)) + val = ck.get(key, default) + if (not val) and key in COOKIE_DEFAULTS: + return COOKIE_DEFAULTS[key] + return val #deco's: def deluge_page_noauth(func): @@ -327,7 +336,7 @@ def create_webserver(urls,methods): __all__ = ['deluge_page_noauth', 'deluge_page', 'remote', 'auto_refreshed', 'check_session', 'do_redirect', 'error_page','start_session','getcookie' - ,'create_webserver'] + ,'create_webserver','setcookie']