summaryrefslogtreecommitdiffstats
path: root/testapi/opnfv_testapi/handlers/base_handlers.py
diff options
context:
space:
mode:
authorSerenaFeng <feng.xiaowei@zte.com.cn>2017-12-07 04:04:09 +0800
committerSerenaFeng <feng.xiaowei@zte.com.cn>2018-01-02 10:47:15 +0800
commitf505dab1f5f26154619ec5c30cabbd8efaad173e (patch)
tree212e39f635abf72e41d5335be23895b31384c8f6 /testapi/opnfv_testapi/handlers/base_handlers.py
parent25345fc94b0cfa24df4fc37cf4aa6befeaefad59 (diff)
leverage query_by_name decorator to simplify name querying
name query is case insensitive and partial match Change-Id: I65a6f5d3aa9411559cb9cf27d0fbd7ec46d4b26f Signed-off-by: SerenaFeng <feng.xiaowei@zte.com.cn>
Diffstat (limited to 'testapi/opnfv_testapi/handlers/base_handlers.py')
-rw-r--r--testapi/opnfv_testapi/handlers/base_handlers.py8
1 files changed, 3 insertions, 5 deletions
diff --git a/testapi/opnfv_testapi/handlers/base_handlers.py b/testapi/opnfv_testapi/handlers/base_handlers.py
index a2fdb19..bc91f64 100644
--- a/testapi/opnfv_testapi/handlers/base_handlers.py
+++ b/testapi/opnfv_testapi/handlers/base_handlers.py
@@ -103,7 +103,8 @@ class GenericApiHandler(web.RequestHandler):
@web.asynchronous
@gen.coroutine
- def _list(self, query=None, res_op=None, *args, **kwargs):
+ @check.query_by_name
+ def _list(self, query=None, **kwargs):
sort = kwargs.get('sort')
page = kwargs.get('page', 0)
last = kwargs.get('last', 0)
@@ -131,10 +132,7 @@ class GenericApiHandler(web.RequestHandler):
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:
- res = res_op(data, *args)
+ res = {self.table: data}
if page > 0:
res.update({
'pagination': {