def enable_depot(): # DEPOT setup from depot.manager import DepotManager DepotManager.configure('contact_images', config, 'depot.contact_images.') DepotManager.alias('contact_image', 'contact_images')
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)
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)
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
def enable_depot(): import logging log = logging.getLogger('molepaw.depot') # DEPOT setup from depot.manager import DepotManager storages = { 'category_images': 'category_image', } for storage in storages: prefix = 'depot.%s.' % storage log.info('Configuring Storage %s*', prefix) DepotManager.configure(storage, tg.config, prefix) DepotManager.alias(storages[storage], storage)
def enable_depot(app): import logging log = logging.getLogger('stroller2.depot') # DEPOT setup from depot.manager import DepotManager storages = { 'product_images': 'product_image' } for storage in storages: prefix = 'depot.%s.' % storage log.info('Configuring Storage %s*', prefix) DepotManager.configure(storage, tg.config, prefix) DepotManager.alias(storages[storage], storage) return app
def init_app(self, app): storage_conf = app.config.get("DEPOT_MEDIA_STORAGES", {}) if not storage_conf: raise LookupError(""" Media storage config is required when using the media extension. Please add `DEPOT_MEDIA_STORAGES` to the app config, """) if "media_storage" not in storage_conf: raise ValueError( "A storage named *media_storage* is required when configuring `DEPOT_STORAGES`." ) for name, opts in storage_conf.items(): if name not in DepotManager._depots: DepotManager.configure(name, opts) for storage in ("image_storage", "document_storage"): if storage not in DepotManager._depots: DepotManager.alias(storage, "media_storage") if app.config.get("SERVE_MEDIA_FILES"): self._add_serving_routes(app)
def test_alias_on_existing_storage(self): DepotManager.configure('mystorage', {'depot.storage_path': './lfs2'}) DepotManager.alias('mystorage', 'mystorage')
def test_aliases_not_existing(self): DepotManager.alias('used_storage', 'first')