forked from github.com/pypiserver
do not use the default bottle app
This commit is contained in:
parent
c0f82470c6
commit
1b2f37ede5
@ -17,8 +17,10 @@ def app(root=None,
|
||||
|
||||
os.listdir(root)
|
||||
_app.configure(root=root, redirect_to_fallback=redirect_to_fallback, fallback_url=fallback_url)
|
||||
_app.app.module = _app
|
||||
|
||||
bottle.debug(True)
|
||||
return bottle.default_app()
|
||||
return _app.app
|
||||
|
||||
|
||||
def paste_app_factory(global_config, **local_conf):
|
||||
|
@ -5,9 +5,10 @@ if sys.version_info >= (3, 0):
|
||||
else:
|
||||
from urlparse import urljoin
|
||||
|
||||
from bottle import route, static_file, redirect, request, HTTPError
|
||||
from bottle import static_file, redirect, request, HTTPError, Bottle
|
||||
from pypiserver import __version__
|
||||
from pypiserver.core import is_allowed_path
|
||||
|
||||
packages = None
|
||||
|
||||
class configuration(object):
|
||||
@ -33,13 +34,15 @@ def configure(root=None,
|
||||
config.redirect_to_fallback = redirect_to_fallback
|
||||
config.fallback_url = fallback_url
|
||||
|
||||
app = Bottle()
|
||||
|
||||
@route("/favicon.ico")
|
||||
|
||||
@app.route("/favicon.ico")
|
||||
def favicon():
|
||||
return HTTPError(404)
|
||||
|
||||
|
||||
@route('/')
|
||||
@app.route('/')
|
||||
def root():
|
||||
try:
|
||||
numpkgs = len(packages.find_packages())
|
||||
@ -67,12 +70,12 @@ easy_install -i %(URL)ssimple/ PACKAGE
|
||||
""" % dict(URL=request.url, VERSION=__version__, NUMPKGS=numpkgs)
|
||||
|
||||
|
||||
@route("/simple")
|
||||
@app.route("/simple")
|
||||
def simpleindex_redirect():
|
||||
return redirect(request.fullpath + "/")
|
||||
|
||||
|
||||
@route("/simple/")
|
||||
@app.route("/simple/")
|
||||
def simpleindex():
|
||||
prefixes = list(packages.find_prefixes())
|
||||
prefixes.sort()
|
||||
@ -83,8 +86,8 @@ def simpleindex():
|
||||
return "".join(res)
|
||||
|
||||
|
||||
@route("/simple/:prefix")
|
||||
@route("/simple/:prefix/")
|
||||
@app.route("/simple/:prefix")
|
||||
@app.route("/simple/:prefix/")
|
||||
def simple(prefix=""):
|
||||
fp = request.fullpath
|
||||
if not fp.endswith("/"):
|
||||
@ -106,8 +109,8 @@ def simple(prefix=""):
|
||||
return "".join(res)
|
||||
|
||||
|
||||
@route('/packages')
|
||||
@route('/packages/')
|
||||
@app.route('/packages')
|
||||
@app.route('/packages/')
|
||||
def list_packages():
|
||||
fp = request.fullpath
|
||||
if not fp.endswith("/"):
|
||||
@ -122,7 +125,7 @@ def list_packages():
|
||||
return "".join(res)
|
||||
|
||||
|
||||
@route('/packages/:filename#.*#')
|
||||
@app.route('/packages/:filename#.*#')
|
||||
def server_static(filename):
|
||||
if not is_allowed_path(filename):
|
||||
return HTTPError(404)
|
||||
@ -130,8 +133,8 @@ def server_static(filename):
|
||||
return static_file(filename, root=packages.root)
|
||||
|
||||
|
||||
@route('/:prefix')
|
||||
@route('/:prefix/')
|
||||
@app.route('/:prefix')
|
||||
@app.route('/:prefix/')
|
||||
def bad_url(prefix):
|
||||
p = request.fullpath
|
||||
if not p.endswith("/"):
|
||||
@ -139,5 +142,3 @@ def bad_url(prefix):
|
||||
p += "../simple/%s/" % prefix
|
||||
|
||||
return redirect(p)
|
||||
|
||||
# return redirect("../simple/%s/" % prefix)
|
||||
|
@ -3,9 +3,9 @@
|
||||
|
||||
import os, sys, getopt, re, mimetypes
|
||||
|
||||
from pypiserver import bottle, __version__
|
||||
from pypiserver import bottle, __version__, app
|
||||
sys.modules["bottle"] = bottle
|
||||
from bottle import run, debug, server_names
|
||||
from bottle import run, server_names
|
||||
|
||||
mimetypes.add_type("application/octet-stream", ".egg")
|
||||
|
||||
@ -196,12 +196,10 @@ def main(argv=None):
|
||||
manage.update(packages, update_directory, update_dry_run, stable_only=update_stable_only)
|
||||
return
|
||||
|
||||
from pypiserver import _app
|
||||
_app.configure(root=root, redirect_to_fallback=redirect_to_fallback)
|
||||
a = app(root=root, redirect_to_fallback=redirect_to_fallback)
|
||||
server = server or "auto"
|
||||
debug(True)
|
||||
sys.stdout.write("This is pypiserver %s serving %r on %s:%s\n\n" % (__version__, root, host, port))
|
||||
run(host=host, port=port, server=server)
|
||||
run(app=a, host=host, port=port, server=server)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -50,8 +50,8 @@ accesslog = -
|
||||
|
||||
twill.add_wsgi_intercept("nonroot", 80, lambda: loadapp("config:%s" % pini))
|
||||
|
||||
twill.add_wsgi_intercept("localhost", 8080, bottle.default_app)
|
||||
twill.add_wsgi_intercept("systemexit.de", 80, bottle.default_app)
|
||||
twill.add_wsgi_intercept("localhost", 8080, lambda: _app.app)
|
||||
twill.add_wsgi_intercept("systemexit.de", 80, lambda: _app.app)
|
||||
twill.add_wsgi_intercept("pypi.python.org", 80, lambda: fallback_app)
|
||||
|
||||
def cleanup():
|
||||
|
@ -23,6 +23,7 @@ def pytest_funcarg__main(request):
|
||||
|
||||
def run(**kwargs):
|
||||
print "RUN:", kwargs
|
||||
kwargs.pop("app")
|
||||
main.run_kwargs = kwargs
|
||||
|
||||
def listdir(pkgdir):
|
||||
|
Loading…
Reference in New Issue
Block a user