当前位置: 首页>>代码示例>>Python>>正文


Python Model.getAccountOne方法代码示例

本文整理汇总了Python中model.Model.getAccountOne方法的典型用法代码示例。如果您正苦于以下问题:Python Model.getAccountOne方法的具体用法?Python Model.getAccountOne怎么用?Python Model.getAccountOne使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在model.Model的用法示例。


在下文中一共展示了Model.getAccountOne方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: login

# 需要导入模块: from model import Model [as 别名]
# 或者: from model.Model import getAccountOne [as 别名]
def login(name,password):
    '''

    :param name:
    :param password:
    :return:  {"status":1, "username":user,"is_manager":False,"is_super_manager":False}
    '''
    try:
        ret=requests.post(API_URL+'login', {'user_name':name,'password':password}).json()
        if ret['status']=='1':
            user= ret['username']
            if user:
                handler = Model('Account')
                _find_user_result = handler.getAccountOne(user)
            if  _find_user_result:
                time_now = timestamptodate(time.time())
                handler.UpdateAccountPrivilege(user,ret['is_manager'],ret['is_super_manager'])
                handler.updateAccountLogintime(user,time_now)
            else:
                time_now = timestamptodate(time.time())
                user_data = {"username":user,"is_manager":ret['is_manager'],"is_super_manager":ret['is_super_manager'],"login_time":time_now,"register_time":time_now}
                handler.InsertAccount(user_data)
            return 1
        else:
            return 0
    except Exception as er:

        return 0
开发者ID:sjqzhang,项目名称:lvs-manager,代码行数:30,代码来源:control.py

示例2: user_is_manager

# 需要导入模块: from model import Model [as 别名]
# 或者: from model.Model import getAccountOne [as 别名]
def user_is_manager(user):
    handler = Model('LvsAccount')
    user_info = handler.getAccountOne(user)
    if user_info['is_manager'] or user_info['is_super_manager'] :
        return True
    else:
        return False
开发者ID:sjqzhang,项目名称:lvs-manager,代码行数:9,代码来源:control.py

示例3: get

# 需要导入模块: from model import Model [as 别名]
# 或者: from model.Model import getAccountOne [as 别名]
 def get(self):
     '''
     user login
     '''
     ticket = self.get_argument("t", None)
     lvs_url = options.lvs_url
     ksso_url = options.ksso_url
     _request = urllib2.Request("%sverify?t=%s" % (ksso_url,ticket))
     _request.add_header("referer",lvs_url)
     res = urllib2.urlopen(_request)
     user = res.read()
     if user == 'False':
         raise tornado.web.HTTPError(500, 'Ksso Retrun False')
     if user:
         handler = Model('Account')
         _find_user_result = handler.getAccountOne(user)
         if  _find_user_result:
             time_now = timestamptodate(time.time())
             handler.updateAccountLogintime(user,time_now)
         else:
             time_now = timestamptodate(time.time())
             user_data = {"username":user,"is_manager":False,"is_super_manager":False,"login_time":time_now,"register_time":time_now}
             handler.InsertAccount(user_data)
     self.set_secure_cookie("user", user,expires_days=options.cookies_expires)
     self.redirect('/charts/')
开发者ID:Quanse,项目名称:lvs-manager,代码行数:27,代码来源:control.py

示例4: get

# 需要导入模块: from model import Model [as 别名]
# 或者: from model.Model import getAccountOne [as 别名]
 def get(self):
     '''
     show lvsmanager.html
     '''
     config = yaml.load(open(options.config))
     current_user = self.get_current_user()
     handler = Model('LvsAccount')
     user_info = handler.getAccountOne(current_user)
     if user_info['is_super_manager']:
         cluster_list = config['cluster']
     elif user_info['is_manager']:
         cluster_list = [ i for i in config['cluster'] if current_user in i['manager_user'] ]
     else:
         cluster_list = []
         #self.write('Permission denied !!')
     
     for cluster in cluster_list:
         lb_list = []
         for lb in cluster['agent']:
             lb_info = search_agent(lb)
             lb_list.append({"id":lb_info['id'],"ipadd":lb_info['ipadd']})
         cluster['lb'] = lb_list
     self.render2('lvsmanager.html',cluster_list=cluster_list)
开发者ID:sjqzhang,项目名称:lvs-manager,代码行数:25,代码来源:control.py


注:本文中的model.Model.getAccountOne方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。