Skip to content

Commit

Permalink
Fixed marker & limit computation (bug 1006055)
Browse files Browse the repository at this point in the history
Change-Id: I8a4a7b114b05e36024753cd02189188fd4294fc1
  • Loading branch information
dolph authored and openstack-gerrit committed Jun 28, 2012
1 parent 8cd73c7 commit 002dd42
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions keystone/identity/core.py
Expand Up @@ -414,18 +414,19 @@ def get_tenant_users(self, context, tenant_id, **kw):

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)
Expand All @@ -434,8 +435,9 @@ def _format_tenant_list(self, tenant_refs, **kwargs):
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:
Expand Down

0 comments on commit 002dd42

Please sign in to comment.