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


Python QueryHelper.get_operator_by_oid方法代码示例

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


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

示例1: get

# 需要导入模块: from helpers.queryhelper import QueryHelper [as 别名]
# 或者: from helpers.queryhelper.QueryHelper import get_operator_by_oid [as 别名]
 def get(self):
     """Display profile of current operator.
     """
     status = ErrorCode.SUCCESS
     try: 
         profile = DotDict()
         # 1: user     
         oper = QueryHelper.get_operator_by_oid(self.current_user.oid, self.db)
         if not oper:
             status = ErrorCode.LOGIN_AGAIN
             logging.error("[UWEB] Operator does not exist, redirect to login.html. oid: %s.", 
                           self.current_user.oid)
             self.write_ret(status)
             return
         
         profile.update(oper)
         for key in profile.keys():
             profile[key] = profile[key] if profile[key] else ''
         self.write_ret(status,
                        dict_=dict(profile=profile))
     except Exception as e:
         logging.exception("[UWEB] Get corp profile failed. oid:%s, tid:%s, Exception: %s", 
                           self.current_user.oid, self.current_user.tid, e.args) 
         status = ErrorCode.SERVER_BUSY
         self.write_ret(status)
开发者ID:jcsy521,项目名称:ydws,代码行数:27,代码来源:profile.py

示例2: get

# 需要导入模块: from helpers.queryhelper import QueryHelper [as 别名]
# 或者: from helpers.queryhelper.QueryHelper import get_operator_by_oid [as 别名]
    def get(self):
        status=ErrorCode.SUCCESS
        # from_ = self.get_argument('from', '').lower()
        index_html = "index.html"
        bizcode = None
        name = ''
        if self.current_user.oid != UWEB.DUMMY_OID: # operator
            index_html = "index_corp.html"
            umobile=self.current_user.oid
            user_info = QueryHelper.get_operator_by_oid(self.current_user.oid, self.db)
            corp_info = QueryHelper.get_corp_by_oid(self.current_user.oid, self.db)
            if user_info:
                name = user_info.name if user_info.name else user_info.mobile 
            user_type = UWEB.USER_TYPE.OPERATOR
            bizcode = corp_info.bizcode
        elif self.current_user.cid != UWEB.DUMMY_CID: # corp
            index_html = "index_corp.html"
            umobile=self.current_user.cid
            user_info = QueryHelper.get_corp_by_cid(self.current_user.cid, self.db)
            if user_info:
                name = user_info.c_linkman if user_info.c_linkman else user_info.c_mobile 
            user_type = UWEB.USER_TYPE.CORP
            bizcode = user_info.bizcode
        else: # user
            umobile=self.current_user.uid
            user_info = QueryHelper.get_user_by_uid(self.current_user.uid, self.db)
            if user_info:
                name = user_info.name if user_info.name else user_info.mobile 
            user_type = UWEB.USER_TYPE.PERSON

        if not user_info:
            status = ErrorCode.LOGIN_AGAIN
            logging.error("The user with uid: %s does not exist, redirect to login.html", self.current_user.uid)
            self.render("login.html",
                        username='',
                        password='',
                        user_type=UWEB.USER_TYPE.PERSON,
                        message=None,
                        message_captcha=None)
            return

        static_hash = self.redis.get('static_hash')
        static_hash = static_hash if static_hash else u'dummy_hash'

        wspush = dict(id='', 
                      key='') 
        json_data = WSPushHelper.register_wspush(umobile, self.redis) 
        if json_data: 
            data = json_data['data'] 
            id = data.get('push_id', '') 
            key = data.get('psd', '') 
            wspush['id'] = id
            wspush['key'] = key

        self.render(index_html,
                    map_type=ConfHelper.LBMP_CONF.map_type,
                    user_type=user_type,
                    bizcode=bizcode,
                    status=status,
                    name=name,
                    umobile=umobile,
                    static_hash=static_hash,
                    wspush=wspush,)
开发者ID:jcsy521,项目名称:ydws,代码行数:65,代码来源:main.py

示例3: post

# 需要导入模块: from helpers.queryhelper import QueryHelper [as 别名]
# 或者: from helpers.queryhelper.QueryHelper import get_operator_by_oid [as 别名]
    def post(self):
        """Retrieve the password."""
        status = ErrorCode.SUCCESS
        try:
            data = DotDict(json_decode(self.request.body))
            mobile = data.mobile
            captcha = data.get('captcha','')
            logging.info("[UWEB] corp retrieve password request: %s", 
                         data)
        except Exception as e:
            status = ErrorCode.ILLEGAL_DATA_FORMAT
            self.write_ret(status)
            return 

        try:
            status = ErrorCode.SUCCESS
            psd = get_psd()                        
            user = QueryHelper.get_corp_by_cid(mobile, self.db)         
            if user: # corp
                psd_info = dict(user_id=mobile,
                                user_type=UWEB.USER_TYPE.CORP,
                                password=psd)
                if not captcha: # old version 
                    update_password(psd_info, self.db, self.redis)
                else: # new version
                    captcha_key = get_captcha_key(mobile)
                    captcha_old = self.redis.get(captcha_key)
                    if captcha_old:
                        if captcha == str(captcha_old):                            
                            update_password(psd_info, self.db, self.redis)
                        else:
                            status = ErrorCode.WRONG_CAPTCHA
                            logging.error("[UWEB] Crop retrieve password failed."
                                          "  mobile: %s, captcha: %s, captcha_old: %s, Message: %s", 
                                          mobile, captcha, captcha_old, ErrorCode.ERROR_MESSAGE[status])
                    else:
                        status = ErrorCode.NO_CAPTCHA
                        logging.error("[UWEB] Corp retrieve password failed. "
                                      "  mobile: %s, captcha: %s, Message: %s", 
                                      mobile, captcha, ErrorCode.ERROR_MESSAGE[status])
            else: 
                user = QueryHelper.get_operator_by_oid(mobile, self.db)
                if user: # operator
                    psd_info = dict(user_id=mobile,
                                    user_type=UWEB.USER_TYPE.OPERATOR,
                                    password=psd)
                    if not captcha: # old version
                        update_password(psd_info, self.db, self.redis)
                    else: # new version
                        captcha_key = get_captcha_key(mobile)
                        captcha_old = self.redis.get(captcha_key)
                        if captcha_old:
                            if captcha == str(captcha_old):        
                                update_password(psd_info, self.db, self.redis)
                            else:
                                status = ErrorCode.WRONG_CAPTCHA
                                logging.error("[UWEB] Operator retrieve password failed. "
                                              "  mobile: %s, captcha: %s, captcha_old: %s, Message: %s", 
                                               mobile, captcha, captcha_old, ErrorCode.ERROR_MESSAGE[status])
                        else:
                            status = ErrorCode.NO_CAPTCHA
                            logging.error("[UWEB] Operator retrieve password failed. "
                                          "  mobile: %s, captcha: %s, Message: %s", 
                                          mobile, captcha, ErrorCode.ERROR_MESSAGE[status])
                else:
                    status = ErrorCode.USER_NOT_ORDERED
                    logging.error("[UWEB] Operator does not exist, retrieve password failed. mobile: %s", 
                                  mobile)

            if status == ErrorCode.SUCCESS:
                retrieve_password_sms = SMSCode.SMS_RETRIEVE_PASSWORD % (psd) 
                ret = SMSHelper.send(mobile, retrieve_password_sms)
                ret = DotDict(json_decode(ret))
                if ret.status == ErrorCode.SUCCESS:
                    logging.info("[UWEB] Corp retrieve password success, "
                                 "  mobile: %s, the new passwrod: %s", 
                                 mobile, psd)
                else:
                    status = ErrorCode.SERVER_BUSY
                    logging.error("[UWEB] Corp retrieve password failed. mobile: %s", 
                                  mobile)
            self.write_ret(status)
        except Exception as e:
            logging.exception("[UWEB] Corp retrieve password failed. mobile: %s, Exception: %s", 
                              mobile, e.args)
            status = ErrorCode.SERVER_BUSY
            self.write_ret(status)
开发者ID:jcsy521,项目名称:ydws,代码行数:89,代码来源:password.py


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