本文整理汇总了Python中depot.manager.DepotManager.make_middleware方法的典型用法代码示例。如果您正苦于以下问题:Python DepotManager.make_middleware方法的具体用法?Python DepotManager.make_middleware怎么用?Python DepotManager.make_middleware使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类depot.manager.DepotManager
的用法示例。
在下文中一共展示了DepotManager.make_middleware方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_invalid_mountpoint
# 需要导入模块: from depot.manager import DepotManager [as 别名]
# 或者: from depot.manager.DepotManager import make_middleware [as 别名]
def test_invalid_mountpoint(self):
try:
DepotManager.make_middleware(self.wsgi_app, mountpoint='hello')
except ValueError as err:
assert 'mountpoint must be an absolute path' in str(err)
else:
assert False, 'Should have raised ValueError'
示例2: setup
# 需要导入模块: from depot.manager import DepotManager [as 别名]
# 或者: from depot.manager.DepotManager import make_middleware [as 别名]
def setup():
setup_database()
DepotManager._clear()
DepotManager.configure('default', {'depot.storage_path': './lfs'})
DepotManager.configure('another', {'depot.storage_path': './lfs'})
DepotManager.alias('another_alias', 'another')
DepotManager.make_middleware(None)
示例3: make_app
# 需要导入模块: from depot.manager import DepotManager [as 别名]
# 或者: from depot.manager.DepotManager import make_middleware [as 别名]
def make_app(global_conf, full_stack=True, **app_conf):
"""
Set depotexample up with the settings found in the PasteDeploy configuration
file used.
:param global_conf: The global settings for depotexample (those
defined under the ``[DEFAULT]`` section).
:type global_conf: dict
:param full_stack: Should the whole TG2 stack be set up?
:type full_stack: str or bool
:return: The depotexample application with all the relevant middleware
loaded.
This is the PasteDeploy factory for the depotexample application.
``app_conf`` contains all the application-specific settings (those defined
under ``[app:main]``.
"""
app = make_base_app(global_conf, full_stack=True, **app_conf)
# Wrap your base TurboGears 2 application with custom middleware here
from depot.manager import DepotManager
app = DepotManager.make_middleware(app)
return app
示例4: make_app
# 需要导入模块: from depot.manager import DepotManager [as 别名]
# 或者: from depot.manager.DepotManager import make_middleware [as 别名]
def make_app(self, **options):
wsgi_app = DepotManager.make_middleware(self.wsgi_app, **options)
return TestApp(wsgi_app)
示例5: get_wsgi_application
# 需要导入模块: from depot.manager import DepotManager [as 别名]
# 或者: from depot.manager.DepotManager import make_middleware [as 别名]
"""
WSGI config for depotexample project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/
"""
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "depotexample.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
# Configure a "default" storage based on DEPOT settings
from django.conf import settings
from depot.manager import DepotManager
DepotManager.configure('default', settings.DEPOT, prefix='')
# Wrap the application with depot middleware to serve files on /depot
application = DepotManager.make_middleware(application)
示例6: test_prevent_multiple_middlewares
# 需要导入模块: from depot.manager import DepotManager [as 别名]
# 或者: from depot.manager.DepotManager import make_middleware [as 别名]
def test_prevent_multiple_middlewares(self):
DepotManager.make_middleware(None)
DepotManager.make_middleware(None)
示例7: Flask
# 需要导入模块: from depot.manager import DepotManager [as 别名]
# 或者: from depot.manager.DepotManager import make_middleware [as 别名]
from flask import Flask, request, redirect, url_for, render_template
app = Flask(__name__)
# This is just an horrible way to keep around
# uploaded files, but in the end we just wanted
# to showcase how to setup DEPOT, not how to upload files.
UPLOADED_FILES = []
@app.route("/", methods=['GET', 'POST'])
def index():
if request.method == 'POST':
file = request.files['file']
if file:
fileid = DepotManager.get().create(file)
UPLOADED_FILES.append(fileid)
return redirect(url_for('index'))
files = [DepotManager.get().get(fileid) for fileid in UPLOADED_FILES]
return render_template('index.html', files=files)
from depot.manager import DepotManager
DepotManager.configure('default', {'depot.storage_path': '/tmp/'})
app.wsgi_app = DepotManager.make_middleware(app.wsgi_app)
if __name__ == "__main__":
app.run(host='0.0.0.0', port=5001, debug=True)