You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2011/04/09 15:14:42 UTC
svn commit: r1090583 -
/incubator/libcloud/trunk/libcloud/storage/drivers/cloudfiles.py
Author: tomaz
Date: Sat Apr 9 13:14:39 2011
New Revision: 1090583
URL: http://svn.apache.org/viewvc?rev=1090583&view=rev
Log:
Modify CloudFiles driver to use _get_object method from the base class.
Modified:
incubator/libcloud/trunk/libcloud/storage/drivers/cloudfiles.py
Modified: incubator/libcloud/trunk/libcloud/storage/drivers/cloudfiles.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/libcloud/storage/drivers/cloudfiles.py?rev=1090583&r1=1090582&r2=1090583&view=diff
==============================================================================
--- incubator/libcloud/trunk/libcloud/storage/drivers/cloudfiles.py (original)
+++ incubator/libcloud/trunk/libcloud/storage/drivers/cloudfiles.py Sat Apr 9 13:14:39 2011
@@ -242,15 +242,31 @@ class CloudFilesStorageDriver(StorageDri
def download_object(self, obj, destination_path, overwrite_existing=False,
delete_on_failure=True):
- return self._get_object(obj, self._save_object,
- {'obj': obj,
+ container_name = obj.container.name
+ object_name = obj.name
+ response = self.connection.request('/%s/%s' % (container_name,
+ object_name),
+ method='GET', raw=True)
+
+ return self._get_object(obj=obj, callback=self._save_object,
+ response=response,
+ callback_kwargs={'obj': obj,
'destination_path': destination_path,
'overwrite_existing': overwrite_existing,
- 'delete_on_failure': delete_on_failure})
+ 'delete_on_failure': delete_on_failure},
+ success_status_code=httplib.OK)
def download_object_as_stream(self, obj, chunk_size=None):
- return self._get_object(obj, self._get_object_as_stream,
- {'chunk_size': chunk_size})
+ container_name = obj.container.name
+ object_name = obj.name
+ response = self.connection.request('/%s/%s' % (container_name,
+ object_name),
+ method='GET', raw=True)
+
+ return self._get_object(obj=obj, callback=self._save_object,
+ response=response,
+ callback_kwargs={'chunk_size': chunk_size},
+ success_status_code=httplib.OK)
def upload_object(self, file_path, container, object_name, extra=None,
file_hash=None):
@@ -295,26 +311,6 @@ class CloudFilesStorageDriver(StorageDri
raise LibcloudError('Unexpected status code: %s' % (response.status))
- def _get_object(self, obj, callback, callback_args):
- container_name = obj.container.name
- object_name = obj.name
-
- response = self.connection.request('/%s/%s' % (container_name,
- object_name),
- raw=True)
-
- callback_args['response'] = response.response
-
- if response.status == httplib.OK:
- return callback(**callback_args)
- elif response.status == httplib.NOT_FOUND:
- raise ObjectDoesNotExistError(
- object_name=object_name,
- driver=self,
- value='')
-
- raise LibcloudError('Unexpected status code: %s' % (response.status))
-
def _put_object(self, upload_func, upload_func_args, container, object_name,
extra=None, file_path=None, iterator=None, file_hash=None):
container_name_cleaned = self._clean_container_name(container.name)