From 4882f5cb88010e2e06aaba47b90a6203f6a17f28 Mon Sep 17 00:00:00 2001 From: Martijn Voncken Date: Mon, 17 Mar 2008 20:47:27 +0000 Subject: [PATCH] refactor:webpy022->web.py --- deluge/ui/webui/config_forms.py | 4 ++-- deluge/ui/webui/debugerror.py | 8 +++++--- deluge/ui/webui/deluge_webserver.py | 11 ++++++++--- deluge/ui/webui/json_api.py | 2 +- deluge/ui/webui/lib/newforms_plus.py | 8 +------- deluge/ui/webui/lib/static_handler.py | 4 ++-- deluge/ui/webui/lib/webpy022/wsgi.py | 10 +++++----- deluge/ui/webui/page_decorators.py | 6 +++--- deluge/ui/webui/pages.py | 9 ++------- deluge/ui/webui/plugin_manager.py | 2 +- deluge/ui/webui/render.py | 2 +- deluge/ui/webui/torrent_add.py | 2 +- deluge/ui/webui/torrent_move.py | 2 +- deluge/ui/webui/torrent_options.py | 2 +- deluge/ui/webui/utils.py | 10 +++++----- deluge/ui/webui/web.py | 4 ++++ 16 files changed, 43 insertions(+), 43 deletions(-) create mode 100644 deluge/ui/webui/web.py diff --git a/deluge/ui/webui/config_forms.py b/deluge/ui/webui/config_forms.py index 472b274d4..7ae53a95f 100644 --- a/deluge/ui/webui/config_forms.py +++ b/deluge/ui/webui/config_forms.py @@ -33,10 +33,10 @@ import lib.newforms_plus as forms import page_decorators as deco -import lib.webpy022 as web +import web from webserver_common import ws, proxy, log from render import render -from lib.webpy022.http import seeother +from web import seeother import sys import os import utils diff --git a/deluge/ui/webui/debugerror.py b/deluge/ui/webui/debugerror.py index 5570f357e..96f1fe07e 100644 --- a/deluge/ui/webui/debugerror.py +++ b/deluge/ui/webui/debugerror.py @@ -38,12 +38,14 @@ pretty_errors_cls = { } import sys, urlparse, pprint -from lib.webpy022.net import websafe -from lib.webpy022.template import Template -import lib.webpy022.webapi as web +from web import websafe +from web import template +import web #import lib.webpy022.webapi as web import webserver_common as ws from traceback import format_tb +Template = template.Template + import os, os.path whereami = os.path.join(os.getcwd(), __file__) whereami = os.path.sep.join(whereami.split(os.path.sep)[:-1]) diff --git a/deluge/ui/webui/deluge_webserver.py b/deluge/ui/webui/deluge_webserver.py index 5f7c847a4..ea4ff8a01 100644 --- a/deluge/ui/webui/deluge_webserver.py +++ b/deluge/ui/webui/deluge_webserver.py @@ -41,13 +41,18 @@ import config_tabs_webui #auto registers in ConfigUiManager import config_tabs_deluge #auto registers in ConfigUiManager import register_menu +#debugerror +from debugerror import deluge_debugerror +import web +web.webapi.internalerror = deluge_debugerror + from webserver_common import ws #todo: remove ws. def create_webserver(urls, methods, middleware): from webserver_common import ws - from lib.webpy022.request import webpyfunc - from lib.webpy022 import webapi + from web import webpyfunc + from web import webapi from lib.gtk_cherrypy_wsgiserver import CherryPyWSGIServer import os @@ -63,7 +68,7 @@ def create_webserver(urls, methods, middleware): return server def WebServer(debug = False): - import lib.webpy022 as web + import web from deluge import component if debug: middleware = [web.reloader] diff --git a/deluge/ui/webui/json_api.py b/deluge/ui/webui/json_api.py index e159fbd02..9459a3f4c 100644 --- a/deluge/ui/webui/json_api.py +++ b/deluge/ui/webui/json_api.py @@ -41,7 +41,7 @@ from inspect import getargspec from utils import get_torrent_status,get_category_choosers, get_stats,filter_torrent_state,fsize,fspeed from page_decorators import remote from operator import attrgetter -import lib.webpy022 as web +import web from webserver_common import proxy, log def to_json(obj): diff --git a/deluge/ui/webui/lib/newforms_plus.py b/deluge/ui/webui/lib/newforms_plus.py index 50f8c5ac9..ae55664d7 100644 --- a/deluge/ui/webui/lib/newforms_plus.py +++ b/deluge/ui/webui/lib/newforms_plus.py @@ -10,13 +10,7 @@ from newforms.forms import BoundField import sys, os -import webpy022 as web #todo:remove this dependency. - - - - - - +import web #Form class FilteredForm(newforms.Form): diff --git a/deluge/ui/webui/lib/static_handler.py b/deluge/ui/webui/lib/static_handler.py index 829d97792..98322a9ea 100644 --- a/deluge/ui/webui/lib/static_handler.py +++ b/deluge/ui/webui/lib/static_handler.py @@ -6,8 +6,8 @@ static fileserving for web.py without the need for wsgi wrapper magic. """ -import webpy022 as web -from webpy022.http import seeother, url +import web +from web import seeother, url import posixpath import urlparse diff --git a/deluge/ui/webui/lib/webpy022/wsgi.py b/deluge/ui/webui/lib/webpy022/wsgi.py index 26abf9291..e7a79f9fb 100644 --- a/deluge/ui/webui/lib/webpy022/wsgi.py +++ b/deluge/ui/webui/lib/webpy022/wsgi.py @@ -10,7 +10,7 @@ import webapi as web from utils import listget from net import validaddr, validip import httpserver - + def runfcgi(func, addr=('localhost', 8000)): """Runs a WSGI function as a FastCGI server.""" import flup.server.fcgi as flups @@ -26,14 +26,14 @@ def runwsgi(func): Runs a WSGI-compatible `func` using FCGI, SCGI, or a simple web server, as appropriate based on context and `sys.argv`. """ - + if os.environ.has_key('SERVER_SOFTWARE'): # cgi os.environ['FCGI_FORCE_CGI'] = 'Y' if (os.environ.has_key('PHP_FCGI_CHILDREN') #lighttpd fastcgi or os.environ.has_key('SERVER_SOFTWARE')): return runfcgi(func, None) - + if 'fcgi' in sys.argv or 'fastcgi' in sys.argv: args = sys.argv[1:] if 'fastcgi' in args: args.remove('fastcgi') @@ -42,7 +42,7 @@ def runwsgi(func): return runfcgi(func, validaddr(args[0])) else: return runfcgi(func, None) - + if 'scgi' in sys.argv: args = sys.argv[1:] args.remove('scgi') @@ -50,5 +50,5 @@ def runwsgi(func): return runscgi(func, validaddr(args[0])) else: return runscgi(func) - + return httpserver.runsimple(func, validip(listget(sys.argv, 1, ''))) diff --git a/deluge/ui/webui/page_decorators.py b/deluge/ui/webui/page_decorators.py index 2c326f96f..ce479aae4 100644 --- a/deluge/ui/webui/page_decorators.py +++ b/deluge/ui/webui/page_decorators.py @@ -7,9 +7,9 @@ from webserver_common import ws, log, proxy from utils import * #/relative -from lib.webpy022.webapi import cookies, setcookie as w_setcookie -from lib.webpy022.http import seeother, url -from lib.webpy022 import changequery as self_url +from web import cookies, setcookie as w_setcookie +from web import seeother, url +from web import changequery as self_url #deco's: def deluge_page_noauth(func): diff --git a/deluge/ui/webui/pages.py b/deluge/ui/webui/pages.py index e5837b521..2e2a796a5 100644 --- a/deluge/ui/webui/pages.py +++ b/deluge/ui/webui/pages.py @@ -45,12 +45,8 @@ from torrent_move import torrent_move from deluge.common import get_pixmap -#debugerror -from debugerror import deluge_debugerror -web.webapi.internalerror = deluge_debugerror - -import lib.webpy022 as web -from lib.webpy022.http import seeother, url +import web +from web import seeother, url from lib.static_handler import static_handler from torrent_add import torrent_add @@ -62,7 +58,6 @@ page_manager = component.get("PageManager") #from json_api import json_api #secuity leak, todo:fix - #routing: urls = [ "/login", "login", diff --git a/deluge/ui/webui/plugin_manager.py b/deluge/ui/webui/plugin_manager.py index d05ba0b0e..47a5d1d9f 100644 --- a/deluge/ui/webui/plugin_manager.py +++ b/deluge/ui/webui/plugin_manager.py @@ -53,7 +53,7 @@ class PluginManager(pluginmanagerbase.PluginManagerBase, self.disable_plugins() def _on_get_enabled_plugins(self, enabled_plugins): - log.debug("Core has these plugins enabled: %s", enabled_plugins) + log.debug("Webui has these plugins enabled: %s", enabled_plugins) self.config["enabled_plugins"] = enabled_plugins # Enable the plugins that are enabled in the config and core diff --git a/deluge/ui/webui/render.py b/deluge/ui/webui/render.py index ea15d55b9..b69c144be 100644 --- a/deluge/ui/webui/render.py +++ b/deluge/ui/webui/render.py @@ -34,7 +34,7 @@ from webserver_common import ws,REVNO,VERSION from utils import * #/relative from deluge import common -from lib.webpy022 import changequery as self_url, template, Storage +from web import changequery as self_url, template, Storage import os class subclassed_render(object): diff --git a/deluge/ui/webui/torrent_add.py b/deluge/ui/webui/torrent_add.py index 0eb66276b..49c9f19f3 100644 --- a/deluge/ui/webui/torrent_add.py +++ b/deluge/ui/webui/torrent_add.py @@ -34,7 +34,7 @@ import utils from render import render, error_page import page_decorators as deco import lib.newforms_plus as forms -import lib.webpy022 as web +import web class OptionsForm(forms.Form): download_location = forms.ServerFolder(_("Download Location")) diff --git a/deluge/ui/webui/torrent_move.py b/deluge/ui/webui/torrent_move.py index 9660c7a9e..ec1ed4de8 100644 --- a/deluge/ui/webui/torrent_move.py +++ b/deluge/ui/webui/torrent_move.py @@ -35,7 +35,7 @@ import utils from render import render import page_decorators as deco import lib.newforms_plus as forms -import lib.webpy022 as web +import web #Too much boilerplate code here, todo : fix it. diff --git a/deluge/ui/webui/torrent_options.py b/deluge/ui/webui/torrent_options.py index 1329a29fb..feaaade3c 100644 --- a/deluge/ui/webui/torrent_options.py +++ b/deluge/ui/webui/torrent_options.py @@ -34,7 +34,7 @@ import utils from render import template import page_decorators as deco import lib.newforms_plus as forms -import lib.webpy022 as web +import web class TorrentOptionsForm(forms.Form): diff --git a/deluge/ui/webui/utils.py b/deluge/ui/webui/utils.py index f8f810452..0409c2b77 100644 --- a/deluge/ui/webui/utils.py +++ b/deluge/ui/webui/utils.py @@ -30,12 +30,12 @@ # 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 lib.webpy022 as web +import web import os -from lib.webpy022.webapi import cookies, setcookie as w_setcookie -from lib.webpy022 import changequery as self_url, template -from lib.webpy022.utils import Storage -from lib.webpy022.http import seeother, url +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 diff --git a/deluge/ui/webui/web.py b/deluge/ui/webui/web.py new file mode 100644 index 000000000..c1fca2b54 --- /dev/null +++ b/deluge/ui/webui/web.py @@ -0,0 +1,4 @@ +#compatibility: use the included version/release of web.py. +from lib.webpy022 import * +print 'tpl=',template +print list(sorted(globals().keys()))