Refactoring to move ContainerItem and ContainerListing.
authorDaira Hopwood <daira@jacaranda.org>
Fri, 4 Apr 2014 14:38:55 +0000 (15:38 +0100)
committerDaira Hopwood <daira@jacaranda.org>
Fri, 17 Apr 2015 21:31:41 +0000 (22:31 +0100)
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
src/allmydata/storage/backends/base.py
src/allmydata/storage/backends/cloud/cloud_common.py
src/allmydata/storage/backends/cloud/googlestorage/googlestorage_container.py
src/allmydata/storage/backends/cloud/mock_cloud.py
src/allmydata/storage/backends/cloud/msazure/msazure_container.py
src/allmydata/storage/backends/cloud/openstack/openstack_container.py
src/allmydata/test/test_storage.py

index 7513dba7229eb54a793127c6a0daca337413d969..ff45bc5c1ee88ee83f81745f5b46d10b97b69a91 100644 (file)
@@ -4,6 +4,7 @@ from weakref import WeakValueDictionary
 from twisted.application import service
 from twisted.internet import defer
 
+from allmydata.util.assertutil import precondition
 from allmydata.util.deferredutil import async_iterate, gatherResults
 from allmydata.storage.common import si_b2a
 from allmydata.storage.bucket import BucketReader
@@ -244,3 +245,53 @@ def empty_check_testv(testv):
             test_good = False
             break
     return test_good
+
+
+# Originally from txaws.s3.model (under different class names), which was under the MIT / Expat licence.
+
+class ContainerItem(object):
+    """
+    An item in a listing of cloud objects.
+    """
+    def __init__(self, key, modification_date, etag, size, storage_class,
+                 owner=None):
+        self.key = key
+        self.modification_date = modification_date
+        self.etag = etag
+        self.size = size
+        self.storage_class = storage_class
+        self.owner = owner
+
+    def __repr__(self):
+        return "<ContainerItem %r>" % ({
+                   "key": self.key,
+                   "modification_date": self.modification_date,
+                   "etag": self.etag,
+                   "size": self.size,
+                   "storage_class": self.storage_class,
+                   "owner": self.owner,
+               },)
+
+
+class ContainerListing(object):
+    def __init__(self, name, prefix, marker, max_keys, is_truncated,
+                 contents=None, common_prefixes=None):
+        precondition(isinstance(is_truncated, str))
+        self.name = name
+        self.prefix = prefix
+        self.marker = marker
+        self.max_keys = max_keys
+        self.is_truncated = is_truncated
+        self.contents = contents
+        self.common_prefixes = common_prefixes
+
+    def __repr__(self):
+        return "<ContainerListing %r>" % ({
+                   "name": self.name,
+                   "prefix": self.prefix,
+                   "marker": self.marker,
+                   "max_keys": self.max_keys,
+                   "is_truncated": self.is_truncated,
+                   "contents": self.contents,
+                   "common_prefixes": self.common_prefixes,
+               })
index f07e3814dfefa3d815338c54877035a95b63d3c4..461ca807b2f648a560060e6f34fbc777fa3961ef 100644 (file)
@@ -281,56 +281,6 @@ class CloudServiceError(Error):
         raise NotImplementedError
 
 
-# Originally from txaws.s3.model (under different class names), which was under the MIT / Expat licence.
-
-class ContainerItem(object):
-    """
-    An item in a listing of cloud objects.
-    """
-    def __init__(self, key, modification_date, etag, size, storage_class,
-                 owner=None):
-        self.key = key
-        self.modification_date = modification_date
-        self.etag = etag
-        self.size = size
-        self.storage_class = storage_class
-        self.owner = owner
-
-    def __repr__(self):
-        return "<ContainerItem %r>" % ({
-                   "key": self.key,
-                   "modification_date": self.modification_date,
-                   "etag": self.etag,
-                   "size": self.size,
-                   "storage_class": self.storage_class,
-                   "owner": self.owner,
-               },)
-
-
-class ContainerListing(object):
-    def __init__(self, name, prefix, marker, max_keys, is_truncated,
-                 contents=None, common_prefixes=None):
-        precondition(isinstance(is_truncated, str))
-        self.name = name
-        self.prefix = prefix
-        self.marker = marker
-        self.max_keys = max_keys
-        self.is_truncated = is_truncated
-        self.contents = contents
-        self.common_prefixes = common_prefixes
-
-    def __repr__(self):
-        return "<ContainerListing %r>" % ({
-                   "name": self.name,
-                   "prefix": self.prefix,
-                   "marker": self.marker,
-                   "max_keys": self.max_keys,
-                   "is_truncated": self.is_truncated,
-                   "contents": self.contents,
-                   "common_prefixes": self.common_prefixes,
-               })
-
-
 BACKOFF_SECONDS_BEFORE_RETRY = (0, 2, 10)
 
 
index 6294f4a3160fa026127c984e575edd4c7fbec727..cc5794df3579f7658f95451449d3c978079884f8 100644 (file)
@@ -29,8 +29,9 @@ except ImportError:
 from zope.interface import implements
 
 from allmydata.util import log
+from allmydata.storage.backends.base import ContainerItem, ContainerListing
 from allmydata.storage.backends.cloud.cloud_common import IContainer, \
-     ContainerItem, ContainerListing, CommonContainerMixin, HTTPClientMixin
+     CommonContainerMixin, HTTPClientMixin
 
 
 class AuthenticationClient(object):
index 6894e6cc9881d81d1a6c6753f0a5ba94bfd28b5f..dcb6f85c168e218a9fd7e21bf53cedb9824fbbfe 100644 (file)
@@ -8,9 +8,9 @@ from allmydata.util.deferredutil import async_iterate
 from zope.interface import implements
 
 from allmydata.util.assertutil import _assert
+from allmydata.storage.backends.base import ContainerItem, ContainerListing
 from allmydata.storage.backends.cloud.cloud_common import IContainer, \
-     CloudServiceError, ContainerItem, ContainerListing, \
-     CommonContainerMixin, ContainerListMixin
+     CloudServiceError, CommonContainerMixin, ContainerListMixin
 from allmydata.util.time_format import iso_utc
 from allmydata.util import fileutil
 
index 8b6c987bb95c9f8564d5f65a1ac43b696cc16198..fec3d08b1b01c2554f03726893e4cd7af2250c0e 100644 (file)
@@ -21,8 +21,9 @@ from zope.interface import implements
 from twisted.web.http_headers import Headers
 from twisted.web.http import datetimeToString
 
+from allmydata.storage.backends.base import ContainerItem, ContainerListing
 from allmydata.storage.backends.cloud.cloud_common import IContainer, \
-     ContainerItem, ContainerListing, CommonContainerMixin, HTTPClientMixin
+     CommonContainerMixin, HTTPClientMixin
 
 
 class MSAzureStorageContainer(CommonContainerMixin, HTTPClientMixin):
index 6e8c323b3f1eb81bdfe23b0dc647cebe5f3b8d91..384accaa18b8e297fc546e319ff2818d52433f9c 100644 (file)
@@ -10,9 +10,9 @@ from zope.interface import implements, Interface
 
 from allmydata.util import log
 from allmydata.node import InvalidValueError
+from allmydata.storage.backends.base import ContainerItem, ContainerListing
 from allmydata.storage.backends.cloud.cloud_common import IContainer, \
-     CloudServiceError, ContainerItem, ContainerListing, CommonContainerMixin, \
-     HTTPClientMixin
+     CloudServiceError, CommonContainerMixin, HTTPClientMixin
 
 
 # Enabling this will cause secrets to be logged.
index 911023f6884e341c256a104be03ea7a49ddfe886..558f07b5f9365723717870861b9545d06b389ce3 100644 (file)
@@ -22,14 +22,14 @@ from allmydata import interfaces
 from allmydata.util.assertutil import precondition
 from allmydata.util import fileutil, hashutil, base32, time_format
 from allmydata.storage.server import StorageServer
+from allmydata.storage.backends.base import ContainerItem, ContainerListing
 from allmydata.storage.backends.null.null_backend import NullBackend
 from allmydata.storage.backends.disk.disk_backend import DiskBackend
 from allmydata.storage.backends.disk.immutable import load_immutable_disk_share, \
      create_immutable_disk_share, ImmutableDiskShare
 from allmydata.storage.backends.disk.mutable import create_mutable_disk_share, MutableDiskShare
 from allmydata.storage.backends.cloud.cloud_backend import CloudBackend
-from allmydata.storage.backends.cloud.cloud_common import CloudError, CloudServiceError, \
-     ContainerItem, ContainerListing
+from allmydata.storage.backends.cloud.cloud_common import CloudError, CloudServiceError
 from allmydata.storage.backends.cloud.mutable import MutableCloudShare
 from allmydata.storage.backends.cloud import mock_cloud, cloud_common
 from allmydata.storage.backends.cloud.mock_cloud import MockContainer