Remove the inner-classing-ness of StorageObjectWrapper
This commit is contained in:
parent
781be9ee6f
commit
4dea708cd3
@ -228,30 +228,11 @@ class BasicFileStorage(StorageInterface):
|
|||||||
return self._resolve_filepath(filepath)
|
return self._resolve_filepath(filepath)
|
||||||
|
|
||||||
|
|
||||||
|
# ----------------------------------------------------
|
||||||
|
# OpenStack/Rackspace Cloud's Swift/CloudFiles support
|
||||||
|
# ----------------------------------------------------
|
||||||
|
|
||||||
class CloudFilesStorage(StorageInterface):
|
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)
|
|
||||||
|
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
self.param_container = kwargs.get('cloudfiles_container')
|
self.param_container = kwargs.get('cloudfiles_container')
|
||||||
self.param_user = kwargs.get('cloudfiles_user')
|
self.param_user = kwargs.get('cloudfiles_user')
|
||||||
@ -324,6 +305,33 @@ class CloudFilesStorage(StorageInterface):
|
|||||||
self._resolve_filepath(filepath)])
|
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):
|
class MountStorage(StorageInterface):
|
||||||
"""
|
"""
|
||||||
Experimental "Mount" virtual Storage Interface
|
Experimental "Mount" virtual Storage Interface
|
||||||
|
Loading…
x
Reference in New Issue
Block a user