aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/storage.py
diff options
context:
space:
mode:
authorChristopher Allan Webber <cwebber@dustycloud.org>2011-08-21 13:51:05 -0500
committerChristopher Allan Webber <cwebber@dustycloud.org>2011-08-21 13:51:05 -0500
commitbd3b566dbecdcc9e0ee0f919e63ae753869db187 (patch)
treedf7ed67455b7bb20840dd1cc857a102f73de19a9 /mediagoblin/storage.py
parentae72c6381475408d83bfcf702c8eed7d4d80c1f5 (diff)
parent758eb746547cc8c6c52135fd88bee11b5f81d3d4 (diff)
downloadmediagoblin-bd3b566dbecdcc9e0ee0f919e63ae753869db187.tar.lz
mediagoblin-bd3b566dbecdcc9e0ee0f919e63ae753869db187.tar.xz
mediagoblin-bd3b566dbecdcc9e0ee0f919e63ae753869db187.zip
Merge remote branch 'remotes/elrond/dev/storage_config'
Diffstat (limited to 'mediagoblin/storage.py')
-rw-r--r--mediagoblin/storage.py28
1 files changed, 10 insertions, 18 deletions
diff --git a/mediagoblin/storage.py b/mediagoblin/storage.py
index 3968fa29..d484be1f 100644
--- a/mediagoblin/storage.py
+++ b/mediagoblin/storage.py
@@ -15,7 +15,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
-import re
import shutil
import urlparse
import uuid
@@ -456,41 +455,34 @@ def clean_listy_filepath(listy_filepath):
return cleaned_filepath
-def storage_system_from_config(paste_config, storage_prefix):
+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(
base_url='/media/',
base_dir='/var/whatever/media')
"""
- prefix_re = re.compile('^%s_(.+)$' % re.escape(storage_prefix))
-
- config_params = dict(
- [(prefix_re.match(key).groups()[0], value)
- for key, value in paste_config.iteritems()
- if prefix_re.match(key)])
+ # This construct is needed, because dict(config) does
+ # not replace the variables in the config items.
+ config_params = dict(config_section.iteritems())
if 'storage_class' in config_params:
storage_class = config_params['storage_class']