commit 0c6ab9df4002129174686ca073c6e3e9262397d5
Author: Sofia Papagiannaki <spapagian@grnet.gr>
Date:   Thu Feb 20 18:40:48 2014 +0200

    pithos: Fix TypeError when listing over-populated containers
    
    Update tests
    
    Refs: #5119

diff --git a/snf-pithos-backend/pithos/backends/modular.py b/snf-pithos-backend/pithos/backends/modular.py
index 3753425..4b8a41b 100644
--- a/snf-pithos-backend/pithos/backends/modular.py
+++ b/snf-pithos-backend/pithos/backends/modular.py
@@ -683,7 +683,7 @@ class ModularBackend(BaseBackend):
     @debug_method
     @backend_method
     def delete_container(self, user, account, container, until=None, prefix='',
-                         delimiter=None):
+                         delimiter=None, listing_limit=None):
         """Delete/purge the container with the given name."""
 
         self._can_write_container(user, account, container)
@@ -731,7 +731,8 @@ class ModularBackend(BaseBackend):
             src_names = self._list_objects_no_limit(
                 user, account, container, prefix='', delimiter=None,
                 virtual=False, domain=None, keys=[], shared=False, until=None,
-                size_range=None, all_props=True, public=False)
+                size_range=None, all_props=True, public=False,
+                listing_limit=listing_limit)
             paths = []
             for t in src_names:
                 path = '/'.join((account, container, t[0]))
@@ -820,11 +821,12 @@ class ModularBackend(BaseBackend):
 
     def _list_objects_no_limit(self, user, account, container, prefix,
                                delimiter, virtual, domain, keys, shared, until,
-                               size_range, all_props, public):
+                               size_range, all_props, public,
+                               listing_limit=10000):
         objects = []
         while True:
-            marker = objects[-1] if objects else None
-            limit = 10000
+            marker = objects[-1][0] if objects else None
+            limit = listing_limit
             l = self._list_objects(
                 user, account, container, prefix, delimiter, marker, limit,
                 virtual, domain, keys, shared, until, size_range, all_props,
@@ -1207,7 +1209,7 @@ class ModularBackend(BaseBackend):
                      dest_account, dest_container, dest_name, type,
                      dest_domain=None, dest_meta=None, replace_meta=False,
                      permissions=None, src_version=None, is_move=False,
-                     delimiter=None):
+                     delimiter=None, listing_limit=10000):
 
         report_size_change = not is_move
         dest_meta = dest_meta or {}
@@ -1249,7 +1251,8 @@ class ModularBackend(BaseBackend):
             src_names = self._list_objects_no_limit(
                 user, src_account, src_container, prefix, delimiter=None,
                 virtual=False, domain=None, keys=[], shared=False, until=None,
-                size_range=None, all_props=True, public=False)
+                size_range=None, all_props=True, public=False,
+                listing_limit=listing_limit)
             src_names.sort(key=lambda x: x[2])  # order by nodes
             paths = [elem[0] for elem in src_names]
             nodes = [elem[2] for elem in src_names]
@@ -1284,14 +1287,15 @@ class ModularBackend(BaseBackend):
     def copy_object(self, user, src_account, src_container, src_name,
                     dest_account, dest_container, dest_name, type, domain,
                     meta=None, replace_meta=False, permissions=None,
-                    src_version=None, delimiter=None):
+                    src_version=None, delimiter=None, listing_limit=None):
         """Copy an object's data and metadata."""
 
         meta = meta or {}
         dest_version_id = self._copy_object(
             user, src_account, src_container, src_name, dest_account,
             dest_container, dest_name, type, domain, meta, replace_meta,
-            permissions, src_version, False, delimiter)
+            permissions, src_version, False, delimiter,
+            listing_limit=listing_limit)
         return dest_version_id
 
     @debug_method
@@ -1299,7 +1303,7 @@ class ModularBackend(BaseBackend):
     def move_object(self, user, src_account, src_container, src_name,
                     dest_account, dest_container, dest_name, type, domain,
                     meta=None, replace_meta=False, permissions=None,
-                    delimiter=None):
+                    delimiter=None, listing_limit=None):
         """Move an object's data and metadata."""
 
         meta = meta or {}
@@ -1308,11 +1312,13 @@ class ModularBackend(BaseBackend):
         dest_version_id = self._move_object(
             user, src_account, src_container, src_name, dest_account,
             dest_container, dest_name, type, domain, meta, replace_meta,
-            permissions, None, delimiter=delimiter)
+            permissions, None, delimiter=delimiter,
+            listing_limit=listing_limit)
         return dest_version_id
 
     def _delete_object(self, user, account, container, name, until=None,
-                       delimiter=None, report_size_change=True):
+                       delimiter=None, report_size_change=True,
+                       listing_limit=None):
         if user != account:
             raise NotAllowedError
 
@@ -1377,7 +1383,8 @@ class ModularBackend(BaseBackend):
             src_names = self._list_objects_no_limit(
                 user, account, container, prefix, delimiter=None,
                 virtual=False, domain=None, keys=[], shared=False, until=None,
-                size_range=None, all_props=True, public=False)
+                size_range=None, all_props=True, public=False,
+                listing_limit=listing_limit)
             paths = []
             for t in src_names:
                 path = '/'.join((account, container, t[0]))
@@ -1409,10 +1416,11 @@ class ModularBackend(BaseBackend):
     @debug_method
     @backend_method
     def delete_object(self, user, account, container, name, until=None,
-                      prefix='', delimiter=None):
+                      prefix='', delimiter=None, listing_limit=None):
         """Delete/purge an object."""
 
-        self._delete_object(user, account, container, name, until, delimiter)
+        self._delete_object(user, account, container, name, until, delimiter,
+                            listing_limit=listing_limit)
 
     @debug_method
     @backend_method
