libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r1348323 - in /libcloud/trunk: libcloud/storage/drivers/cloudfiles.py test/storage/test_cloudfiles.py
Date Sat, 09 Jun 2012 05:27:41 GMT
Author: tomaz
Date: Sat Jun  9 05:27:41 2012
New Revision: 1348323

URL: http://svn.apache.org/viewvc?rev=1348323&view=rev
Log:
Add ex_set_error_page method to the CloudFiles driver.

Modified:
    libcloud/trunk/libcloud/storage/drivers/cloudfiles.py
    libcloud/trunk/test/storage/test_cloudfiles.py

Modified: libcloud/trunk/libcloud/storage/drivers/cloudfiles.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/storage/drivers/cloudfiles.py?rev=1348323&r1=1348322&r2=1348323&view=diff
==============================================================================
--- libcloud/trunk/libcloud/storage/drivers/cloudfiles.py (original)
+++ libcloud/trunk/libcloud/storage/drivers/cloudfiles.py Sat Jun  9 05:27:41 2012
@@ -306,6 +306,24 @@ class CloudFilesStorageDriver(StorageDri
 
         return response.status in [ httplib.CREATED, httplib.ACCEPTED ]
 
+    def ex_set_error_page(self, container, file_name='error.html'):
+        """
+        Set a custom error page which is displayed if file is not found and
+        serving of a static website is enabled.
+
+        @param file_name: Name of the object which becomes the error page.
+        @type file_name: C{str}
+        """
+        container_name = container.name
+        headers = {'X-Container-Meta-Web-Error': file_name}
+
+        response = self.connection.request('/%s' % (container_name),
+                                           method='POST',
+                                           headers=headers,
+                                           cdn_request=False)
+
+        return response.status in [ httplib.CREATED, httplib.ACCEPTED ]
+
     def create_container(self, container_name):
         container_name = self._clean_container_name(container_name)
         response = self.connection.request(

Modified: libcloud/trunk/test/storage/test_cloudfiles.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/test/storage/test_cloudfiles.py?rev=1348323&r1=1348322&r2=1348323&view=diff
==============================================================================
--- libcloud/trunk/test/storage/test_cloudfiles.py (original)
+++ libcloud/trunk/test/storage/test_cloudfiles.py Sat Jun  9 05:27:41 2012
@@ -581,6 +581,12 @@ class CloudFilesTests(unittest.TestCase)
                                                       index_file='index.html')
         self.assertTrue(result)
 
+    def test_ex_set_error_page(self):
+        container = Container(name='foo_bar_container', extra={}, driver=self)
+        result = self.driver.ex_set_error_page(container=container,
+                                              file_name='error.html')
+        self.assertTrue(result)
+
     def _remove_test_file(self):
         file_path = os.path.abspath(__file__) + '.temp'
 



Mime
View raw message