aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Allan Webber <cwebber@dustycloud.org>2011-08-31 21:36:24 -0500
committerChristopher Allan Webber <cwebber@dustycloud.org>2011-08-31 21:36:24 -0500
commit4dea708cd3a7066ebdf260640173061cf806f872 (patch)
treebf35eea2c0919ba871694f943235b382395ed740
parent781be9ee6f8dcaa99acbbe552d0e020ebe066117 (diff)
downloadmediagoblin-4dea708cd3a7066ebdf260640173061cf806f872.tar.lz
mediagoblin-4dea708cd3a7066ebdf260640173061cf806f872.tar.xz
mediagoblin-4dea708cd3a7066ebdf260640173061cf806f872.zip
Remove the inner-classing-ness of StorageObjectWrapper
-rw-r--r--mediagoblin/storage.py54
1 files changed, 31 insertions, 23 deletions
diff --git a/mediagoblin/storage.py b/mediagoblin/storage.py
index 9cae0ca6..39c9eafc 100644
--- a/mediagoblin/storage.py
+++ b/mediagoblin/storage.py
@@ -228,30 +228,11 @@ class BasicFileStorage(StorageInterface):
return self._resolve_filepath(filepath)
-class CloudFilesStorage(StorageInterface):
- class StorageObjectWrapper():
- """
- Wrapper for python-cloudfiles's cloudfiles.storage_object.Object
- used to circumvent the mystic `medium.jpg` corruption issue, where
- we had both python-cloudfiles and PIL doing buffering on both
- ends and that breaking things.
-
- This wrapper currently meets mediagoblin's needs for a public_store
- file-like object.
- """
- def __init__(self, storage_object):
- self.storage_object = storage_object
-
- def read(self, *args, **kwargs):
- return self.storage_object.read(*args, **kwargs)
-
- def write(self, data, *args, **kwargs):
- if self.storage_object.size and type(data) == str:
- data = self.read() + data
-
- self.storage_object.write(data, *args, **kwargs)
-
+# ----------------------------------------------------
+# OpenStack/Rackspace Cloud's Swift/CloudFiles support
+# ----------------------------------------------------
+class CloudFilesStorage(StorageInterface):
def __init__(self, **kwargs):
self.param_container = kwargs.get('cloudfiles_container')
self.param_user = kwargs.get('cloudfiles_user')
@@ -324,6 +305,33 @@ class CloudFilesStorage(StorageInterface):
self._resolve_filepath(filepath)])
+class StorageObjectWrapper():
+ """
+ Wrapper for python-cloudfiles's cloudfiles.storage_object.Object
+ used to circumvent the mystic `medium.jpg` corruption issue, where
+ we had both python-cloudfiles and PIL doing buffering on both
+ ends and that breaking things.
+
+ This wrapper currently meets mediagoblin's needs for a public_store
+ file-like object.
+ """
+ def __init__(self, storage_object):
+ self.storage_object = storage_object
+
+ def read(self, *args, **kwargs):
+ return self.storage_object.read(*args, **kwargs)
+
+ def write(self, data, *args, **kwargs):
+ if self.storage_object.size and type(data) == str:
+ data = self.read() + data
+
+ self.storage_object.write(data, *args, **kwargs)
+
+
+# ------------
+# MountStorage
+# ------------
+
class MountStorage(StorageInterface):
"""
Experimental "Mount" virtual Storage Interface