当前位置: 首页>>代码示例>>Python>>正文


Python DepotManager.configure方法代码示例

本文整理汇总了Python中depot.manager.DepotManager.configure方法的典型用法代码示例。如果您正苦于以下问题:Python DepotManager.configure方法的具体用法?Python DepotManager.configure怎么用?Python DepotManager.configure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在depot.manager.DepotManager的用法示例。


在下文中一共展示了DepotManager.configure方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: configure_filedepot

# 需要导入模块: from depot.manager import DepotManager [as 别名]
# 或者: from depot.manager.DepotManager import configure [as 别名]
def configure_filedepot(settings):

    config = extract_depot_settings('kotti.depot.', settings)
    for conf in config:
        name = conf.pop('name')
        if name not in DepotManager._depots:
            DepotManager.configure(name, conf, prefix='')
开发者ID:gitter-badger,项目名称:Kotti,代码行数:9,代码来源:filedepot.py

示例2: test_public_url_gets_redirect

# 需要导入模块: from depot.manager import DepotManager [as 别名]
# 或者: from depot.manager.DepotManager import configure [as 别名]
    def test_public_url_gets_redirect(self):
        try:
            global S3Storage
            from depot.io.awss3 import S3Storage
        except ImportError:
            raise SkipTest('Boto not installed')

        env = os.environ
        access_key_id = env.get('AWS_ACCESS_KEY_ID')
        secret_access_key = env.get('AWS_SECRET_ACCESS_KEY')
        if access_key_id is None or secret_access_key is None:
            raise SkipTest('Amazon S3 credentials not available')

        PID = os.getpid()
        NODE = str(uuid.uuid1()).rsplit('-', 1)[-1]  # Travis runs multiple tests concurrently
        default_bucket_name = 'filedepot-%s' % (access_key_id.lower(), )
        cred = (access_key_id, secret_access_key)
        bucket_name = 'filedepot-testfs-%s-%s-%s' % (access_key_id.lower(), NODE, PID)

        DepotManager.configure('awss3', {'depot.backend': 'depot.io.awss3.S3Storage',
                                         'depot.access_key_id': access_key_id,
                                         'depot.secret_access_key': secret_access_key,
                                         'depot.bucket': bucket_name})
        DepotManager.set_default('awss3')

        app = self.make_app()
        new_file = app.post('/create_file').json

        file_path = DepotManager.url_for('%(uploaded_to)s/%(last)s' % new_file)
        uploaded_file = app.get(file_path)
        assert uploaded_file.body == FILE_CONTENT, uploaded_file
开发者ID:dirn,项目名称:depot,代码行数:33,代码来源:test_wsgi_middleware.py

示例3: configure_filedepot

# 需要导入模块: from depot.manager import DepotManager [as 别名]
# 或者: from depot.manager.DepotManager import configure [as 别名]
def configure_filedepot(settings: Dict[str, str]) -> None:

    config = extract_depot_settings("kotti.depot.", settings)
    for conf in config:
        name = conf.pop("name")
        if name not in DepotManager._depots:
            DepotManager.configure(name, conf, prefix="")
开发者ID:Kotti,项目名称:Kotti,代码行数:9,代码来源:filedepot.py

示例4: setup

# 需要导入模块: from depot.manager import DepotManager [as 别名]
# 或者: from depot.manager.DepotManager import configure [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)
开发者ID:chatid,项目名称:depot,代码行数:10,代码来源:test_fields_sqlalchemy.py

示例5: configure_filedepot

# 需要导入模块: from depot.manager import DepotManager [as 别名]
# 或者: from depot.manager.DepotManager import configure [as 别名]
def configure_filedepot(settings):
    from kotti.util import extract_depot_settings
    from depot.manager import DepotManager

    config = extract_depot_settings("kotti.depot.", settings)
    for conf in config:
        name = conf.pop("name")
        if name not in DepotManager._depots:
            DepotManager.configure(name, conf, prefix="")
开发者ID:altereg0,项目名称:Kotti,代码行数:11,代码来源:filedepot.py

示例6: depot

# 需要导入模块: from depot.manager import DepotManager [as 别名]
# 或者: from depot.manager.DepotManager import configure [as 别名]
def depot(temporary_directory):
    DepotManager.configure('default', {
        'depot.backend': 'depot.io.local.LocalFileStorage',
        'depot.storage_path': temporary_directory
    })

    yield DepotManager.get()

    DepotManager._clear()
开发者ID:OneGov,项目名称:onegov.file,代码行数:11,代码来源:conftest.py

示例7: test_prevent_configuring_two_storages_with_same_name

# 需要导入模块: from depot.manager import DepotManager [as 别名]
# 或者: from depot.manager.DepotManager import configure [as 别名]
    def test_prevent_configuring_two_storages_with_same_name(self):
        DepotManager.configure('first', {'depot.storage_path': './lfs'})

        try:
            DepotManager.configure('first', {'depot.storage_path': './lfs2'})
        except RuntimeError:
            pass
        else:
            assert False, 'Should have raised RunetimeError here'
开发者ID:adamchainz,项目名称:depot,代码行数:11,代码来源:test_depot_manager.py

示例8: configure_depot

# 需要导入模块: from depot.manager import DepotManager [as 别名]
# 或者: from depot.manager.DepotManager import configure [as 别名]
def configure_depot():
    """Configure Depot."""
    depot_storage_name = context.config.get_main_option('depot_storage_name')
    depot_storage_path = context.config.get_main_option('depot_storage_dir')
    depot_storage_settings = {'depot.storage_path': depot_storage_path}
    DepotManager.configure(
        depot_storage_name,
        depot_storage_settings,
    )
开发者ID:lebouquetin,项目名称:tracim,代码行数:11,代码来源:f3852e1349c4_all_files_only_on_disk.py

示例9: configure_depot

# 需要导入模块: from depot.manager import DepotManager [as 别名]
# 或者: from depot.manager.DepotManager import configure [as 别名]
def configure_depot():
    """Configure Depot."""
    depot_storage_name = CFG.get_instance().DEPOT_STORAGE_NAME
    depot_storage_path = CFG.get_instance().DEPOT_STORAGE_DIR
    depot_storage_settings = {'depot.storage_path': depot_storage_path}
    DepotManager.configure(
        depot_storage_name,
        depot_storage_settings,
    )
开发者ID:lebouquetin,项目名称:tracim,代码行数:11,代码来源:app_cfg.py

示例10: test_aliases

# 需要导入模块: from depot.manager import DepotManager [as 别名]
# 或者: from depot.manager.DepotManager import configure [as 别名]
    def test_aliases(self):
        DepotManager.configure('first', {'depot.storage_path': './lfs'})
        DepotManager.configure('second', {'depot.storage_path': './lfs2'})

        DepotManager.alias('used_storage', 'first')
        storage = DepotManager.get('used_storage')
        assert storage.storage_path == './lfs', storage

        DepotManager.alias('used_storage', 'second')
        storage = DepotManager.get('used_storage')
        assert storage.storage_path == './lfs2', storage
开发者ID:adamchainz,项目名称:depot,代码行数:13,代码来源:test_depot_manager.py

示例11: configure_filedepot

# 需要导入模块: from depot.manager import DepotManager [as 别名]
# 或者: from depot.manager.DepotManager import configure [as 别名]
    def configure_filedepot(self):

        # TODO - G.M - 2018-08-08 - [GlobalVar] Refactor Global var
        # of tracim_backend, Be careful DepotManager is a Singleton !

        depot_storage_name = self.DEPOT_STORAGE_NAME
        depot_storage_path = self.DEPOT_STORAGE_DIR
        depot_storage_settings = {'depot.storage_path': depot_storage_path}
        DepotManager.configure(
            depot_storage_name,
            depot_storage_settings,
        )
开发者ID:tracim,项目名称:tracim,代码行数:14,代码来源:config.py

示例12: create_depot

# 需要导入模块: from depot.manager import DepotManager [as 别名]
# 或者: from depot.manager.DepotManager import configure [as 别名]
    def create_depot(self):
        config = {
            'depot.backend': self.depot_backend
        }

        if self.depot_backend.endswith('LocalFileStorage'):
            path = self.bound_storage_path

            if not path.exists():
                path.mkdir()

            config['depot.storage_path'] = str(path)

        elif self.depot_backend.endswith('MemoryFileStorage'):
            pass

        else:
            # implementing non-local file systems is going to be more
            # invloved, because we do not generate external urls yet
            raise NotImplementedError()

        DepotManager.configure(self.bound_depot_id, config)
开发者ID:OneGov,项目名称:onegov.file,代码行数:24,代码来源:integration.py

示例13: get_wsgi_application

# 需要导入模块: from depot.manager import DepotManager [as 别名]
# 或者: from depot.manager.DepotManager import configure [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)
开发者ID:amol-,项目名称:depot,代码行数:24,代码来源:wsgi.py

示例14: Flask

# 需要导入模块: from depot.manager import DepotManager [as 别名]
# 或者: from depot.manager.DepotManager import configure [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)
开发者ID:adamchainz,项目名称:depot,代码行数:31,代码来源:app.py

示例15: SomeAuthenticator

# 需要导入模块: from depot.manager import DepotManager [as 别名]
# 或者: from depot.manager.DepotManager import configure [as 别名]
# base_config.sa_auth.authenticators = [('myauth', SomeAuthenticator()]

# You can add more repoze.who metadata providers to fetch
# user metadata.
# Remember to set base_config.sa_auth.authmetadata to None
# to disable authmetadata and use only your own metadata providers
# base_config.sa_auth.mdproviders = [('myprovider', SomeMDProvider()]

# override this if you would like to provide a different who plugin for
# managing login and logout of your application
base_config.sa_auth.form_plugin = None

# You may optionally define a page where you want users to be redirected to
# on login:
base_config.sa_auth.post_login_url = "/post_login"

# You may optionally define a page where you want users to be redirected to
# on logout:
base_config.sa_auth.post_logout_url = "/post_logout"
try:
    # Enable DebugBar if available, install tgext.debugbar to turn it on
    from tgext.debugbar import enable_debugbar

    enable_debugbar(base_config)
except ImportError:
    pass

from depot.manager import DepotManager

DepotManager.configure("default", {"depot.storage_path": "/tmp/"})
开发者ID:rmoorman,项目名称:depot,代码行数:32,代码来源:app_cfg.py


注:本文中的depot.manager.DepotManager.configure方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。