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 2012/12/06 04:53:24 UTC
svn commit: r1417732 - in /libcloud/trunk: CHANGES
libcloud/storage/drivers/cloudfiles.py
libcloud/test/storage/test_cloudfiles.py
Author: tomaz
Date: Thu Dec 6 03:53:23 2012
New Revision: 1417732
URL: http://svn.apache.org/viewvc?rev=1417732&view=rev
Log:
Add new ex_purge_object_from_cdn method to CloudFiles driver and remove
unsupported / deprecated ex_purge_from_cdn method.
Modified:
libcloud/trunk/CHANGES
libcloud/trunk/libcloud/storage/drivers/cloudfiles.py
libcloud/trunk/libcloud/test/storage/test_cloudfiles.py
Modified: libcloud/trunk/CHANGES
URL: http://svn.apache.org/viewvc/libcloud/trunk/CHANGES?rev=1417732&r1=1417731&r2=1417732&view=diff
==============================================================================
--- libcloud/trunk/CHANGES (original)
+++ libcloud/trunk/CHANGES Thu Dec 6 03:53:23 2012
@@ -82,7 +82,8 @@ Changes with Apache Libcloud in developm
containers (iterate_containers). ; LIBCLOUD-261
[Mahendra M]
- - Add ex_purge_from_cdn method to the CloudFiles driver. ; LIBCLOUD-267
+ - Add ex_purge_object_from_cdn method to the CloudFiles driver.
+ ; LIBCLOUD-267
[Tomaz Muraus]
*) DNS
Modified: libcloud/trunk/libcloud/storage/drivers/cloudfiles.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/storage/drivers/cloudfiles.py?rev=1417732&r1=1417731&r2=1417732&view=diff
==============================================================================
--- libcloud/trunk/libcloud/storage/drivers/cloudfiles.py (original)
+++ libcloud/trunk/libcloud/storage/drivers/cloudfiles.py Thu Dec 6 03:53:23 2012
@@ -404,23 +404,25 @@ class CloudFilesStorageDriver(StorageDri
raise LibcloudError('Unexpected status code: %s' % (response.status))
- def ex_purge_from_cdn(self, container, email=None):
+ def ex_purge_object_from_cdn(self, obj, email=None):
"""
- Purge edge cache for all the objects inside the specified container.
+ Purge edge cache for the specified object.
@param email: Email where a notification will be sent when the job
completes. (optional)
@type email: C{str}
"""
+ container_name = self._clean_container_name(obj.container.name)
+ object_name = self._clean_object_name(obj.name)
headers = {'X-Purge-Email': email} if email else {}
- response = self.connection.request('/%s' % (container.name),
+ response = self.connection.request('/%s/%s' % (container_name,
+ object_name),
method='DELETE',
headers=headers,
cdn_request=True)
- return response.status in [httplib.CREATED, httplib.ACCEPTED,
- httplib.NO_CONTENT]
+ return response.status == httplib.NO_CONTENT
def ex_get_meta_data(self):
"""
Modified: libcloud/trunk/libcloud/test/storage/test_cloudfiles.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/test/storage/test_cloudfiles.py?rev=1417732&r1=1417731&r2=1417732&view=diff
==============================================================================
--- libcloud/trunk/libcloud/test/storage/test_cloudfiles.py (original)
+++ libcloud/trunk/libcloud/test/storage/test_cloudfiles.py Thu Dec 6 03:53:23 2012
@@ -498,18 +498,25 @@ class CloudFilesTests(unittest.TestCase)
self.assertTrue('bytes_used' in meta_data)
self.assertTrue('temp_url_key' in meta_data)
- def test_ex_purge_from_cdn(self):
+ def test_ex_purge_object_from_cdn(self):
CloudFilesMockHttp.type = 'PURGE_SUCCESS'
container = Container(name='foo_bar_container', extra={},
driver=self.driver)
- self.assertTrue(self.driver.ex_purge_from_cdn(container=container))
+ obj = Object(name='object', size=1000, hash=None, extra={},
+ container=container, meta_data=None,
+ driver=self)
+
+ self.assertTrue(self.driver.ex_purge_object_from_cdn(obj=obj))
- def test_ex_purge_from_cdn_with_email(self):
+ def test_ex_purge_object_from_cdn_with_email(self):
CloudFilesMockHttp.type = 'PURGE_SUCCESS_EMAIL'
container = Container(name='foo_bar_container', extra={},
driver=self.driver)
- self.assertTrue(self.driver.ex_purge_from_cdn(container=container,
- email='test@test.com'))
+ obj = Object(name='object', size=1000, hash=None, extra={},
+ container=container, meta_data=None,
+ driver=self)
+ self.assertTrue(self.driver.ex_purge_object_from_cdn(obj=obj,
+ email='test@test.com'))
@mock.patch('os.path.getsize')
def test_ex_multipart_upload_object_for_small_files(self, getsize_mock):
@@ -847,23 +854,23 @@ class CloudFilesMockHttp(StorageMockHttp
status_code = httplib.ACCEPTED
return (status_code, body, headers, httplib.responses[httplib.OK])
- def _v1_MossoCloudFS_foo_bar_container_PURGE_SUCCESS(
+ def _v1_MossoCloudFS_foo_bar_container_object_PURGE_SUCCESS(
self, method, url, body, headers):
if method == 'DELETE':
# test_ex_purge_from_cdn
headers = self.base_headers
- status_code = httplib.ACCEPTED
+ status_code = httplib.NO_CONTENT
return (status_code, body, headers, httplib.responses[httplib.OK])
- def _v1_MossoCloudFS_foo_bar_container_PURGE_SUCCESS_EMAIL(
+ def _v1_MossoCloudFS_foo_bar_container_object_PURGE_SUCCESS_EMAIL(
self, method, url, body, headers):
if method == 'DELETE':
# test_ex_purge_from_cdn_with_email
self.assertEqual(headers['X-Purge-Email'], 'test@test.com')
headers = self.base_headers
- status_code = httplib.ACCEPTED
+ status_code = httplib.NO_CONTENT
return (status_code, body, headers, httplib.responses[httplib.OK])
def _v1_MossoCloudFS_foo_bar_container_NOT_FOUND(