Addresses bug 918608

- limit needs to be an integer

Change-Id: I651dd336437f01f514baeaf880c2c73c9c5fee7b
This commit is contained in:
Ziad Sawalha 2012-01-19 20:10:08 -06:00
parent f2726df39c
commit 45b36369a3
5 changed files with 38 additions and 34 deletions

View File

@ -88,12 +88,12 @@ class EndpointTemplateAPI(api.BaseEndpointTemplateAPI):
filter("id>:marker").params(\
marker='%s' % marker).filter_by(\
service_id=service_id).order_by(\
models.EndpointTemplates.id.desc()).limit(limit).all()
models.EndpointTemplates.id.desc()).limit(int(limit)).all()
else:
return session.query(models.EndpointTemplates).filter_by(\
service_id=service_id).order_by(\
models.EndpointTemplates.id.desc()).\
limit(limit).all()
limit(int(limit)).all()
# pylint: disable=R0912
def get_by_service_get_page_markers(self, service_id, marker, \
@ -115,7 +115,7 @@ class EndpointTemplateAPI(api.BaseEndpointTemplateAPI):
filter_by(service_id=service_id).\
params(marker='%s' % marker).\
order_by(models.EndpointTemplates.id).\
limit(limit).\
limit(int(limit)).\
all()
prev_page = session.query(models.EndpointTemplates).\
filter("id < :marker").\
@ -152,11 +152,11 @@ class EndpointTemplateAPI(api.BaseEndpointTemplateAPI):
return session.query(models.EndpointTemplates).\
filter("id>:marker").params(\
marker='%s' % marker).order_by(\
models.EndpointTemplates.id.desc()).limit(limit).all()
models.EndpointTemplates.id.desc()).limit(int(limit)).all()
else:
return session.query(models.EndpointTemplates).order_by(\
models.EndpointTemplates.id.desc()).\
limit(limit).all()
limit(int(limit)).all()
# pylint: disable=R0912
def get_page_markers(self, marker, limit, session=None):
@ -174,7 +174,7 @@ class EndpointTemplateAPI(api.BaseEndpointTemplateAPI):
filter("id > :marker").\
params(marker='%s' % marker).\
order_by(models.EndpointTemplates.id).\
limit(limit).\
limit(int(limit)).\
all()
prev_page = session.query(models.EndpointTemplates).\
filter("id < :marker").\
@ -215,11 +215,11 @@ class EndpointTemplateAPI(api.BaseEndpointTemplateAPI):
filter(models.Endpoints.tenant_id == tenant_id).\
filter("id >= :marker").params(
marker='%s' % marker).order_by(
models.Endpoints.id).limit(limit).all()
models.Endpoints.id).limit(int(limit)).all()
else:
results = session.query(models.Endpoints).\
filter(models.Endpoints.tenant_id == tenant_id).\
order_by(models.Endpoints.id).limit(limit).all()
order_by(models.Endpoints.id).limit(int(limit)).all()
if hasattr(api.TENANT, 'id_to_uid'):
for result in results:

View File

@ -119,10 +119,10 @@ class RoleAPI(api.BaseRoleAPI):
if marker:
results = session.query(models.Role).filter("id>:marker").params(
marker='%s' % marker).order_by(
models.Role.id.desc()).limit(limit).all()
models.Role.id.desc()).limit(int(limit)).all()
else:
results = session.query(models.Role).order_by(
models.Role.id.desc()).limit(limit).all()
models.Role.id.desc()).limit(int(limit)).all()
return RoleAPI.to_model_list(results)
# pylint: disable=R0912
@ -139,7 +139,7 @@ class RoleAPI(api.BaseRoleAPI):
marker = first.id
next_page = session.query(models.Role).filter("id > :marker").params(
marker='%s' % marker).order_by(
models.Role.id).limit(limit).all()
models.Role.id).limit(int(limit)).all()
prev_page = session.query(models.Role).filter("id < :marker").params(
marker='%s' % marker).order_by(
models.Role.id.desc()).limit(int(limit)).all()
@ -169,11 +169,11 @@ class RoleAPI(api.BaseRoleAPI):
results = session.query(models.Role).filter("id>:marker").params(
marker='%s' % marker).filter_by(
service_id=service_id).order_by(
models.Role.id.desc()).limit(limit).all()
models.Role.id.desc()).limit(int(limit)).all()
else:
results = session.query(models.Role).filter_by(
service_id=service_id).order_by(
models.Role.id.desc()).limit(limit).all()
models.Role.id.desc()).limit(int(limit)).all()
return RoleAPI.to_model_list(results)
# pylint: disable=R0912
@ -194,7 +194,7 @@ class RoleAPI(api.BaseRoleAPI):
next_page = session.query(models.Role).filter("id > :marker").params(
marker='%s' % marker).filter_by(
service_id=service_id).order_by(
models.Role.id).limit(limit).all()
models.Role.id).limit(int(limit)).all()
prev_page = session.query(models.Role).filter("id < :marker").params(
marker='%s' % marker).filter_by(
service_id=service_id).order_by(
@ -271,7 +271,7 @@ class RoleAPI(api.BaseRoleAPI):
filter("id > :marker").\
params(marker='%s' % marker).\
order_by(models.UserRoleAssociation.id).\
limit(limit).\
limit(int(limit)).\
all()
prev_page = query.\
filter("id < :marker").\
@ -317,10 +317,12 @@ class RoleAPI(api.BaseRoleAPI):
if marker:
results = query.filter("id>:marker").params(
marker='%s' % marker).order_by(
models.UserRoleAssociation.id.desc()).limit(limit).all()
models.UserRoleAssociation.id.desc()).limit(
int(limit)).all()
else:
results = query.order_by(
models.UserRoleAssociation.id.desc()).limit(limit).all()
models.UserRoleAssociation.id.desc()).limit(
int(limit)).all()
for result in results:
if hasattr(api.USER, 'uid_to_id'):

View File

@ -115,10 +115,11 @@ class ServiceAPI(api.BaseServiceAPI):
if marker:
return session.query(models.Service).filter("id>:marker").params(\
marker='%s' % marker).order_by(\
models.Service.id.desc()).limit(limit).all()
models.Service.id.desc()).limit(int(limit)).all()
else:
return session.query(models.Service).order_by(\
models.Service.id.desc()).limit(limit).all()
return session.query(models.Service).order_by(
models.Service.id.desc()).limit(
int(limit)).all()
@staticmethod
def get_page_markers(marker, limit, session=None):
@ -135,7 +136,7 @@ class ServiceAPI(api.BaseServiceAPI):
next_page = session.query(models.Service).\
filter("id > :marker").params(\
marker='%s' % marker).order_by(\
models.Service.id).limit(limit).all()
models.Service.id).limit(int(limit)).all()
prev_page = session.query(models.Service).\
filter("id < :marker").params(\
marker='%s' % marker).order_by(\

View File

@ -154,9 +154,9 @@ class TenantAPI(api.BaseTenantAPI):
if marker:
results = q3.filter("tenant.id>:marker").params(\
marker='%s' % marker).order_by(\
tenant.id.desc()).limit(limit).all()
tenant.id.desc()).limit(int(limit)).all()
else:
results = q3.order_by(tenant.id.desc()).limit(limit).all()
results = q3.order_by(tenant.id.desc()).limit(int(limit)).all()
return TenantAPI.to_model_list(results)
@ -193,7 +193,7 @@ class TenantAPI(api.BaseTenantAPI):
if marker is None:
marker = first.id
next_page = q3.filter(tenant.id > marker).order_by(\
tenant.id).limit(limit).all()
tenant.id).limit(int(limit)).all()
prev_page = q3.filter(tenant.id > marker).order_by(\
tenant.id.desc()).limit(int(limit)).all()
if len(next_page) == 0:
@ -224,10 +224,11 @@ class TenantAPI(api.BaseTenantAPI):
tenants = session.query(models.Tenant).\
filter("id>:marker").params(\
marker='%s' % marker).order_by(\
models.Tenant.id.desc()).limit(limit).all()
models.Tenant.id.desc()).limit(int(limit)).all()
else:
tenants = session.query(models.Tenant).order_by(\
models.Tenant.id.desc()).limit(limit).all()
models.Tenant.id.desc()).limit(
int(limit)).all()
return self.to_model_list(tenants)
@ -247,7 +248,7 @@ class TenantAPI(api.BaseTenantAPI):
filter("id > :marker").\
params(marker='%s' % marker).\
order_by(models.Tenant.id).\
limit(limit).\
limit(int(limit)).\
all()
prev_page = session.query(models.Tenant).\
filter("id < :marker").\

View File

@ -141,10 +141,10 @@ class UserAPI(api.BaseUserAPI):
if marker:
results = session.query(models.User).filter("id>:marker").params(\
marker='%s' % marker).order_by(\
models.User.id.desc()).limit(limit).all()
models.User.id.desc()).limit(int(limit)).all()
else:
results = session.query(models.User).order_by(\
models.User.id.desc()).limit(limit).all()
models.User.id.desc()).limit(int(limit)).all()
return UserAPI.to_model_list(results)
@ -163,7 +163,7 @@ class UserAPI(api.BaseUserAPI):
marker = first.id
next_page = session.query(models.User).filter("id > :marker").params(\
marker='%s' % marker).order_by(\
models.User.id).limit(limit).all()
models.User.id).limit(int(limit)).all()
prev_page = session.query(models.User).filter("id < :marker").params(\
marker='%s' % marker).order_by(\
models.User.id.desc()).limit(int(limit)).all()
@ -293,10 +293,10 @@ class UserAPI(api.BaseUserAPI):
results = session.query(user).\
filter("id>=:marker").params(
marker='%s' % marker).order_by(
"id").limit(limit).all()
"id").limit(int(limit)).all()
else:
results = session.query(user).\
order_by("id").limit(limit).all()
order_by("id").limit(int(limit)).all()
return UserAPI.to_model_list(results)
@ -369,12 +369,12 @@ class UserAPI(api.BaseUserAPI):
rv = query.filter("id>=:marker").\
params(marker='%s' % marker).\
order_by("id").\
limit(limit).\
limit(int(limit)).\
all()
else:
rv = query.\
order_by("id").\
limit(limit).\
limit(int(limit)).\
all()
user_ids = set([str(assoc.user_id) for assoc in rv])