diff options
author | Joar Wandborg <joar@wandborg.se> | 2013-03-03 00:11:34 +0100 |
---|---|---|
committer | Joar Wandborg <joar@wandborg.se> | 2013-03-03 00:11:34 +0100 |
commit | e11bc1991d4bf9f470a506ce79ff02c3d3fef3c1 (patch) | |
tree | 939a1eef22ad9cb48cb4b7aba6bc34ca5a3d84a8 /mediagoblin/storage | |
parent | 8b35e7ad158f99bc7d3bb34774a6fde6d06bca67 (diff) | |
download | mediagoblin-e11bc1991d4bf9f470a506ce79ff02c3d3fef3c1.tar.lz mediagoblin-e11bc1991d4bf9f470a506ce79ff02c3d3fef3c1.tar.xz mediagoblin-e11bc1991d4bf9f470a506ce79ff02c3d3fef3c1.zip |
Added .send method to cloudfiles storage object
.. wrapper. Also added some logging - A .warn() for the legacy .write()
method and a .debug() for the new copy_local_to_storage()
Diffstat (limited to 'mediagoblin/storage')
-rw-r--r-- | mediagoblin/storage/cloudfiles.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/mediagoblin/storage/cloudfiles.py b/mediagoblin/storage/cloudfiles.py index e6d21726..b6e57c91 100644 --- a/mediagoblin/storage/cloudfiles.py +++ b/mediagoblin/storage/cloudfiles.py @@ -162,6 +162,7 @@ class CloudFilesStorage(StorageInterface): # and bandwidth usage. So, override this method and use the # Cloudfile's "send" interface instead. # TODO: Fixing write() still seems worthwhile though. + _log.debug('Sending {0} to cloudfiles...'.format(filepath)) with self.get_file(filepath, 'wb') as dest_file: with file(filename, 'rb') as source_file: # Copy to storage system in 4096 byte chunks @@ -196,6 +197,10 @@ class CloudFilesStorageObjectWrapper(): Currently this method does not support any write modes except "append". However if we should need it it would be easy implement. """ + _log.warn( + '{0}.write() has bad performance! Use .send instead for now'\ + .format(self.__class__.__name__)) + if self.storage_object.size and type(data) == str: _log.debug('{0} is > 0 in size, appending data'.format( self.storage_object.name)) @@ -205,9 +210,12 @@ class CloudFilesStorageObjectWrapper(): self.storage_object.name)) self.storage_object.write(data, *args, **kwargs) + def send(self, *args, **kw): + self.storage_object.send(*args, **kw) + def close(self): """ - Not implemented. + Not sure we need anything here. """ pass |