mirror of
https://github.com/codex-storage/deluge.git
synced 2025-01-12 20:44:50 +00:00
refactor:webpy022->web.py
This commit is contained in:
parent
f1cd5071da
commit
4882f5cb88
@ -33,10 +33,10 @@
|
|||||||
|
|
||||||
import lib.newforms_plus as forms
|
import lib.newforms_plus as forms
|
||||||
import page_decorators as deco
|
import page_decorators as deco
|
||||||
import lib.webpy022 as web
|
import web
|
||||||
from webserver_common import ws, proxy, log
|
from webserver_common import ws, proxy, log
|
||||||
from render import render
|
from render import render
|
||||||
from lib.webpy022.http import seeother
|
from web import seeother
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import utils
|
import utils
|
||||||
|
@ -38,12 +38,14 @@ pretty_errors_cls = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
import sys, urlparse, pprint
|
import sys, urlparse, pprint
|
||||||
from lib.webpy022.net import websafe
|
from web import websafe
|
||||||
from lib.webpy022.template import Template
|
from web import template
|
||||||
import lib.webpy022.webapi as web
|
import web #import lib.webpy022.webapi as web
|
||||||
import webserver_common as ws
|
import webserver_common as ws
|
||||||
from traceback import format_tb
|
from traceback import format_tb
|
||||||
|
|
||||||
|
Template = template.Template
|
||||||
|
|
||||||
import os, os.path
|
import os, os.path
|
||||||
whereami = os.path.join(os.getcwd(), __file__)
|
whereami = os.path.join(os.getcwd(), __file__)
|
||||||
whereami = os.path.sep.join(whereami.split(os.path.sep)[:-1])
|
whereami = os.path.sep.join(whereami.split(os.path.sep)[:-1])
|
||||||
|
@ -41,13 +41,18 @@ import config_tabs_webui #auto registers in ConfigUiManager
|
|||||||
import config_tabs_deluge #auto registers in ConfigUiManager
|
import config_tabs_deluge #auto registers in ConfigUiManager
|
||||||
import register_menu
|
import register_menu
|
||||||
|
|
||||||
|
#debugerror
|
||||||
|
from debugerror import deluge_debugerror
|
||||||
|
import web
|
||||||
|
web.webapi.internalerror = deluge_debugerror
|
||||||
|
|
||||||
from webserver_common import ws #todo: remove ws.
|
from webserver_common import ws #todo: remove ws.
|
||||||
|
|
||||||
|
|
||||||
def create_webserver(urls, methods, middleware):
|
def create_webserver(urls, methods, middleware):
|
||||||
from webserver_common import ws
|
from webserver_common import ws
|
||||||
from lib.webpy022.request import webpyfunc
|
from web import webpyfunc
|
||||||
from lib.webpy022 import webapi
|
from web import webapi
|
||||||
from lib.gtk_cherrypy_wsgiserver import CherryPyWSGIServer
|
from lib.gtk_cherrypy_wsgiserver import CherryPyWSGIServer
|
||||||
import os
|
import os
|
||||||
|
|
||||||
@ -63,7 +68,7 @@ def create_webserver(urls, methods, middleware):
|
|||||||
return server
|
return server
|
||||||
|
|
||||||
def WebServer(debug = False):
|
def WebServer(debug = False):
|
||||||
import lib.webpy022 as web
|
import web
|
||||||
from deluge import component
|
from deluge import component
|
||||||
if debug:
|
if debug:
|
||||||
middleware = [web.reloader]
|
middleware = [web.reloader]
|
||||||
|
@ -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 utils import get_torrent_status,get_category_choosers, get_stats,filter_torrent_state,fsize,fspeed
|
||||||
from page_decorators import remote
|
from page_decorators import remote
|
||||||
from operator import attrgetter
|
from operator import attrgetter
|
||||||
import lib.webpy022 as web
|
import web
|
||||||
from webserver_common import proxy, log
|
from webserver_common import proxy, log
|
||||||
|
|
||||||
def to_json(obj):
|
def to_json(obj):
|
||||||
|
@ -10,13 +10,7 @@ from newforms.forms import BoundField
|
|||||||
|
|
||||||
import sys, os
|
import sys, os
|
||||||
|
|
||||||
import webpy022 as web #todo:remove this dependency.
|
import web
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#Form
|
#Form
|
||||||
class FilteredForm(newforms.Form):
|
class FilteredForm(newforms.Form):
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
static fileserving for web.py
|
static fileserving for web.py
|
||||||
without the need for wsgi wrapper magic.
|
without the need for wsgi wrapper magic.
|
||||||
"""
|
"""
|
||||||
import webpy022 as web
|
import web
|
||||||
from webpy022.http import seeother, url
|
from web import seeother, url
|
||||||
|
|
||||||
import posixpath
|
import posixpath
|
||||||
import urlparse
|
import urlparse
|
||||||
|
@ -10,7 +10,7 @@ import webapi as web
|
|||||||
from utils import listget
|
from utils import listget
|
||||||
from net import validaddr, validip
|
from net import validaddr, validip
|
||||||
import httpserver
|
import httpserver
|
||||||
|
|
||||||
def runfcgi(func, addr=('localhost', 8000)):
|
def runfcgi(func, addr=('localhost', 8000)):
|
||||||
"""Runs a WSGI function as a FastCGI server."""
|
"""Runs a WSGI function as a FastCGI server."""
|
||||||
import flup.server.fcgi as flups
|
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,
|
Runs a WSGI-compatible `func` using FCGI, SCGI, or a simple web server,
|
||||||
as appropriate based on context and `sys.argv`.
|
as appropriate based on context and `sys.argv`.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if os.environ.has_key('SERVER_SOFTWARE'): # cgi
|
if os.environ.has_key('SERVER_SOFTWARE'): # cgi
|
||||||
os.environ['FCGI_FORCE_CGI'] = 'Y'
|
os.environ['FCGI_FORCE_CGI'] = 'Y'
|
||||||
|
|
||||||
if (os.environ.has_key('PHP_FCGI_CHILDREN') #lighttpd fastcgi
|
if (os.environ.has_key('PHP_FCGI_CHILDREN') #lighttpd fastcgi
|
||||||
or os.environ.has_key('SERVER_SOFTWARE')):
|
or os.environ.has_key('SERVER_SOFTWARE')):
|
||||||
return runfcgi(func, None)
|
return runfcgi(func, None)
|
||||||
|
|
||||||
if 'fcgi' in sys.argv or 'fastcgi' in sys.argv:
|
if 'fcgi' in sys.argv or 'fastcgi' in sys.argv:
|
||||||
args = sys.argv[1:]
|
args = sys.argv[1:]
|
||||||
if 'fastcgi' in args: args.remove('fastcgi')
|
if 'fastcgi' in args: args.remove('fastcgi')
|
||||||
@ -42,7 +42,7 @@ def runwsgi(func):
|
|||||||
return runfcgi(func, validaddr(args[0]))
|
return runfcgi(func, validaddr(args[0]))
|
||||||
else:
|
else:
|
||||||
return runfcgi(func, None)
|
return runfcgi(func, None)
|
||||||
|
|
||||||
if 'scgi' in sys.argv:
|
if 'scgi' in sys.argv:
|
||||||
args = sys.argv[1:]
|
args = sys.argv[1:]
|
||||||
args.remove('scgi')
|
args.remove('scgi')
|
||||||
@ -50,5 +50,5 @@ def runwsgi(func):
|
|||||||
return runscgi(func, validaddr(args[0]))
|
return runscgi(func, validaddr(args[0]))
|
||||||
else:
|
else:
|
||||||
return runscgi(func)
|
return runscgi(func)
|
||||||
|
|
||||||
return httpserver.runsimple(func, validip(listget(sys.argv, 1, '')))
|
return httpserver.runsimple(func, validip(listget(sys.argv, 1, '')))
|
||||||
|
@ -7,9 +7,9 @@ from webserver_common import ws, log, proxy
|
|||||||
from utils import *
|
from utils import *
|
||||||
#/relative
|
#/relative
|
||||||
|
|
||||||
from lib.webpy022.webapi import cookies, setcookie as w_setcookie
|
from web import cookies, setcookie as w_setcookie
|
||||||
from lib.webpy022.http import seeother, url
|
from web import seeother, url
|
||||||
from lib.webpy022 import changequery as self_url
|
from web import changequery as self_url
|
||||||
|
|
||||||
#deco's:
|
#deco's:
|
||||||
def deluge_page_noauth(func):
|
def deluge_page_noauth(func):
|
||||||
|
@ -45,12 +45,8 @@ from torrent_move import torrent_move
|
|||||||
|
|
||||||
from deluge.common import get_pixmap
|
from deluge.common import get_pixmap
|
||||||
|
|
||||||
#debugerror
|
import web
|
||||||
from debugerror import deluge_debugerror
|
from web import seeother, url
|
||||||
web.webapi.internalerror = deluge_debugerror
|
|
||||||
|
|
||||||
import lib.webpy022 as web
|
|
||||||
from lib.webpy022.http import seeother, url
|
|
||||||
from lib.static_handler import static_handler
|
from lib.static_handler import static_handler
|
||||||
from torrent_add import torrent_add
|
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
|
#from json_api import json_api #secuity leak, todo:fix
|
||||||
|
|
||||||
|
|
||||||
#routing:
|
#routing:
|
||||||
urls = [
|
urls = [
|
||||||
"/login", "login",
|
"/login", "login",
|
||||||
|
@ -53,7 +53,7 @@ class PluginManager(pluginmanagerbase.PluginManagerBase,
|
|||||||
self.disable_plugins()
|
self.disable_plugins()
|
||||||
|
|
||||||
def _on_get_enabled_plugins(self, enabled_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
|
self.config["enabled_plugins"] = enabled_plugins
|
||||||
|
|
||||||
# Enable the plugins that are enabled in the config and core
|
# Enable the plugins that are enabled in the config and core
|
||||||
|
@ -34,7 +34,7 @@ from webserver_common import ws,REVNO,VERSION
|
|||||||
from utils import *
|
from utils import *
|
||||||
#/relative
|
#/relative
|
||||||
from deluge import common
|
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
|
import os
|
||||||
|
|
||||||
class subclassed_render(object):
|
class subclassed_render(object):
|
||||||
|
@ -34,7 +34,7 @@ import utils
|
|||||||
from render import render, error_page
|
from render import render, error_page
|
||||||
import page_decorators as deco
|
import page_decorators as deco
|
||||||
import lib.newforms_plus as forms
|
import lib.newforms_plus as forms
|
||||||
import lib.webpy022 as web
|
import web
|
||||||
|
|
||||||
class OptionsForm(forms.Form):
|
class OptionsForm(forms.Form):
|
||||||
download_location = forms.ServerFolder(_("Download Location"))
|
download_location = forms.ServerFolder(_("Download Location"))
|
||||||
|
@ -35,7 +35,7 @@ import utils
|
|||||||
from render import render
|
from render import render
|
||||||
import page_decorators as deco
|
import page_decorators as deco
|
||||||
import lib.newforms_plus as forms
|
import lib.newforms_plus as forms
|
||||||
import lib.webpy022 as web
|
import web
|
||||||
|
|
||||||
#Too much boilerplate code here, todo : fix it.
|
#Too much boilerplate code here, todo : fix it.
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ import utils
|
|||||||
from render import template
|
from render import template
|
||||||
import page_decorators as deco
|
import page_decorators as deco
|
||||||
import lib.newforms_plus as forms
|
import lib.newforms_plus as forms
|
||||||
import lib.webpy022 as web
|
import web
|
||||||
|
|
||||||
class TorrentOptionsForm(forms.Form):
|
class TorrentOptionsForm(forms.Form):
|
||||||
|
|
||||||
|
@ -30,12 +30,12 @@
|
|||||||
# this exception statement from your version. If you delete this exception
|
# this exception statement from your version. If you delete this exception
|
||||||
# statement from all source files in the program, then also delete it here.
|
# statement from all source files in the program, then also delete it here.
|
||||||
|
|
||||||
import lib.webpy022 as web
|
import web
|
||||||
import os
|
import os
|
||||||
from lib.webpy022.webapi import cookies, setcookie as w_setcookie
|
from web import cookies, setcookie as w_setcookie
|
||||||
from lib.webpy022 import changequery as self_url, template
|
from web import changequery as self_url, template
|
||||||
from lib.webpy022.utils import Storage
|
from web import Storage
|
||||||
from lib.webpy022.http import seeother, url
|
from web import seeother, url
|
||||||
|
|
||||||
from deluge.common import fsize,fspeed,ftime
|
from deluge.common import fsize,fspeed,ftime
|
||||||
|
|
||||||
|
4
deluge/ui/webui/web.py
Normal file
4
deluge/ui/webui/web.py
Normal file
@ -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()))
|
Loading…
x
Reference in New Issue
Block a user