From 002dd429532721392b0676eb42ec1bfb5735c0ea Mon Sep 17 00:00:00 2001 From: Dolph Mathews Date: Fri, 1 Jun 2012 09:35:41 -0500 Subject: Fixed marker & limit computation (bug 1006055) Change-Id: I8a4a7b114b05e36024753cd02189188fd4294fc1 --- keystone/identity/core.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/keystone/identity/core.py b/keystone/identity/core.py index 3caaed5c..aec0b753 100644 --- a/keystone/identity/core.py +++ b/keystone/identity/core.py @@ -414,18 +414,19 @@ class TenantController(wsgi.Application): def _format_tenant_list(self, tenant_refs, **kwargs): marker = kwargs.get('marker') - page_idx = 0 + first_index = 0 if marker is not None: - for (marker_idx, tenant) in enumerate(tenant_refs): + for (marker_index, tenant) in enumerate(tenant_refs): if tenant['id'] == marker: # we start pagination after the marker - page_idx = marker_idx + 1 + first_index = marker_index + 1 break else: msg = 'Marker could not be found' raise exception.ValidationError(message=msg) limit = kwargs.get('limit') + last_index = None if limit is not None: try: limit = int(limit) @@ -434,8 +435,9 @@ class TenantController(wsgi.Application): except (ValueError, AssertionError): msg = 'Invalid limit value' raise exception.ValidationError(message=msg) + last_index = first_index + limit - tenant_refs = tenant_refs[page_idx:limit] + tenant_refs = tenant_refs[first_index:last_index] for x in tenant_refs: if 'enabled' not in x: -- cgit