summaryrefslogtreecommitdiffstats
path: root/utils/test/testapi/opnfv_testapi/ui/auth
diff options
context:
space:
mode:
authorSerenaFeng <feng.xiaowei@zte.com.cn>2017-07-14 19:27:44 +0800
committerSerena Feng <feng.xiaowei@zte.com.cn>2017-07-21 13:34:38 +0000
commit822cd5c32c9a129aa8aad9952f25a37123c96733 (patch)
tree6f4edb8aa5d130a7812b15c70f1186f0138fc560 /utils/test/testapi/opnfv_testapi/ui/auth
parentcbcabf6643e68c019b407c95b1526e77337f7697 (diff)
separate db methods from handler.py
db methods are mingled in handler, which is not well structured Change-Id: I639679d3fc05a0b6528158186b8bf89e0cd10596 Signed-off-by: SerenaFeng <feng.xiaowei@zte.com.cn>
Diffstat (limited to 'utils/test/testapi/opnfv_testapi/ui/auth')
-rw-r--r--utils/test/testapi/opnfv_testapi/ui/auth/sign.py9
-rw-r--r--utils/test/testapi/opnfv_testapi/ui/auth/user.py3
2 files changed, 5 insertions, 7 deletions
diff --git a/utils/test/testapi/opnfv_testapi/ui/auth/sign.py b/utils/test/testapi/opnfv_testapi/ui/auth/sign.py
index 13762c92b..462395225 100644
--- a/utils/test/testapi/opnfv_testapi/ui/auth/sign.py
+++ b/utils/test/testapi/opnfv_testapi/ui/auth/sign.py
@@ -1,14 +1,12 @@
from six.moves.urllib import parse
from tornado import gen
from tornado import web
-import logging
from opnfv_testapi.common.config import CONF
+from opnfv_testapi.db import api as dbapi
from opnfv_testapi.ui.auth import base
from opnfv_testapi.ui.auth import constants as const
-# CONF = config.Config()
-
class SigninHandler(base.BaseHandler):
def get(self):
@@ -48,10 +46,9 @@ class SigninReturnHandler(base.BaseHandler):
'fullname': self.get_query_argument(const.OPENID_NS_SREG_FULLNAME),
const.ROLE: role
}
- user = yield self.db_find_one({'openid': openid})
+ user = yield dbapi.db_find_one(self.table, {'openid': openid})
if not user:
- self.db_save(self.table, new_user_info)
- logging.info('save to db:%s', new_user_info)
+ dbapi.db_save(self.table, new_user_info)
else:
role = user.get(const.ROLE)
diff --git a/utils/test/testapi/opnfv_testapi/ui/auth/user.py b/utils/test/testapi/opnfv_testapi/ui/auth/user.py
index 2fca2a8cb..955cdeead 100644
--- a/utils/test/testapi/opnfv_testapi/ui/auth/user.py
+++ b/utils/test/testapi/opnfv_testapi/ui/auth/user.py
@@ -2,6 +2,7 @@ from tornado import gen
from tornado import web
from opnfv_testapi.common import raises
+from opnfv_testapi.db import api as dbapi
from opnfv_testapi.ui.auth import base
@@ -12,7 +13,7 @@ class ProfileHandler(base.BaseHandler):
openid = self.get_secure_cookie('openid')
if openid:
try:
- user = yield self.db_find_one({'openid': openid})
+ user = yield dbapi.db_find_one(self.table, {'openid': openid})
self.finish_request({
"openid": user.get('openid'),
"email": user.get('email'),