summaryrefslogtreecommitdiffstats
path: root/utils/test/testapi/opnfv_testapi/resources
diff options
context:
space:
mode:
authorSerena Feng <feng.xiaowei@zte.com.cn>2017-08-22 01:42:55 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-08-22 01:42:55 +0000
commitb1965dcda6bd0fd452e73d60bdd8aa258d2d27f1 (patch)
tree3f0f3a568b270483efa2177f5d8fac8e8dbd15a7 /utils/test/testapi/opnfv_testapi/resources
parent69151dce8f4f9bb59c4998fa9e903618265ac0d5 (diff)
parentdf45dd491f4156df70e05ebe98d3d24980b2ead0 (diff)
Merge "bugfix: OperationFailure: the limit must be positive"
Diffstat (limited to 'utils/test/testapi/opnfv_testapi/resources')
-rw-r--r--utils/test/testapi/opnfv_testapi/resources/handlers.py31
1 files changed, 16 insertions, 15 deletions
diff --git a/utils/test/testapi/opnfv_testapi/resources/handlers.py b/utils/test/testapi/opnfv_testapi/resources/handlers.py
index 7090e9973..ed55c7028 100644
--- a/utils/test/testapi/opnfv_testapi/resources/handlers.py
+++ b/utils/test/testapi/opnfv_testapi/resources/handlers.py
@@ -110,22 +110,23 @@ class GenericApiHandler(web.RequestHandler):
pipelines.append({'$match': query})
total_pages = 0
- if page > 0:
- cursor = dbapi.db_list(self.table, query)
- records_count = yield cursor.count()
- total_pages, return_nr = self._calc_total_pages(records_count,
- last,
- page,
- per_page)
- pipelines = self._set_pipelines(pipelines,
- sort,
- return_nr,
- page,
- per_page)
- cursor = dbapi.db_aggregate(self.table, pipelines)
data = list()
- while (yield cursor.fetch_next):
- data.append(self.format_data(cursor.next_object()))
+ cursor = dbapi.db_list(self.table, query)
+ records_count = yield cursor.count()
+ if records_count > 0:
+ if page > 0:
+ total_pages, return_nr = self._calc_total_pages(records_count,
+ last,
+ page,
+ per_page)
+ pipelines = self._set_pipelines(pipelines,
+ sort,
+ return_nr,
+ page,
+ per_page)
+ cursor = dbapi.db_aggregate(self.table, pipelines)
+ while (yield cursor.fetch_next):
+ data.append(self.format_data(cursor.next_object()))
if res_op is None:
res = {self.table: data}
else: