From 758eb746547cc8c6c52135fd88bee11b5f81d3d4 Mon Sep 17 00:00:00 2001 From: Elrond Date: Fri, 12 Aug 2011 13:01:41 +0200 Subject: [PATCH] Document changes to storage_system_from_config Chris suggested changing the docs for storage_system_from_config: - The only param is a config section. - The format of that section is much simpler, no prefix. --- mediagoblin/storage.py | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/mediagoblin/storage.py b/mediagoblin/storage.py index d338fb31..ec3bc1b5 100644 --- a/mediagoblin/storage.py +++ b/mediagoblin/storage.py @@ -15,7 +15,6 @@ # along with this program. If not, see . import os -import re import shutil import urlparse import uuid @@ -443,29 +442,25 @@ def clean_listy_filepath(listy_filepath): return cleaned_filepath -def storage_system_from_config(config): +def storage_system_from_config(config_section): """ - Utility for setting up a storage system from the paste app config. + Utility for setting up a storage system from a config section. - Note that a special argument may be passed in to the paste_config - which is "${storage_prefix}_storage_class" which will provide an + Note that a special argument may be passed in to + the config_section which is "storage_class" which will provide an import path to a storage system. This defaults to "mediagoblin.storage:BasicFileStorage" if otherwise undefined. Arguments: - - paste_config: dictionary of config parameters - - storage_prefix: the storage system we're setting up / will be - getting keys/arguments from. For example 'publicstore' will - grab all arguments that are like 'publicstore_FOO'. + - config_section: dictionary of config parameters Returns: An instantiated storage system. Example: storage_system_from_config( - {'publicstore_base_url': '/media/', - 'publicstore_base_dir': '/var/whatever/media/'}, - 'publicstore') + {'base_url': '/media/', + 'base_dir': '/var/whatever/media/'}) Will return: BasicFileStorage( @@ -474,7 +469,7 @@ def storage_system_from_config(config): """ # This construct is needed, because dict(config) does # not replace the variables in the config items. - config_params = dict(config.iteritems()) + config_params = dict(config_section.iteritems()) if 'storage_class' in config_params: storage_class = config_params['storage_class'] -- 2.25.1