def validae_username_and_pwd(username,pwd): ''' 检测用户名是否存在 :return: ''' query = " select 1 from hb_user where username=%s and pwd=%s " param = (username,pwd) res = yield get_data_from_db(query,param,search_type='one',num = 1,cursor = 'dict') raise gen.Return(res)
def check(*args,**kw): query = " select 1 from hb_user where username=%s " param = ('0001') # 这个可以根据自己需要配置自己的数据库 res = yield get_data_from_db(query,param,search_type='one',num = 1,cursor = 'dict') print 'check_username check....' print res if res: yield func(*args) else: msg_dict = {"code":"1004","msg":u"用户不存在!"} args[0].write(msg_dict)