Ejemplo n.º 1
0
 def _get_data(self):
     r = mc.get(SCRETDB_MC_KEY % self.props_name)
     if r:
         return r
     r = self.secret_db.get(self.props_name) or {}
     mc.set(SCRETDB_MC_KEY % self.props_name, r)
     return r
Ejemplo n.º 2
0
 def get_by_rev(self, rev):
     r = mc.get(SCRETDB_MC_REV_KEY % (self.props_name, rev))
     if r:
         return r
     r = self.secret_db.get(self.props_name, rev=rev)
     mc.set(SCRETDB_MC_REV_KEY % (self.props_name, rev), r)
     return r
Ejemplo n.º 3
0
 def _get_count():
     try:
         r = mc.get(USER_COUNT_MC_KEY)
         if r:
             r = int(r)
             return r
     except:
         return 0
Ejemplo n.º 4
0
def get_ticket():
    ticket = mc.get(CACHE_TICKET_KEY)
    if ticket:
        return ticket

    response = weixin_api.get_js_ticket()
    if response['errcode'] != 0:
        raise RuntimeError('weixin error: %r' % response)
    ticket = response['ticket']
    expires_in = response['expires_in']

    mc.set(
        CACHE_TICKET_KEY,
        ticket,
    )
    mc.expire(CACHE_TICKET_KEY, expires_in)
    return ticket
Ejemplo n.º 5
0
def fetch_account_info(profile):
    """fetch all of the account order info"""
    yixin_account = YixinAccount.get_by_local(profile.account_id)
    if not yixin_account:
        return

    fetch_status = mc.get(
        MC_FETCH_ACCOUNT_STATUS_BY_USER.format(user_id=profile.account_id))
    if fetch_status:
        return profile.person_account_info

    response = yixin.client.query.account_info(token=yixin_account.p2p_token,
                                               timeout=15)

    profile.person_account_info = response.data.p2pservice_list
    sync_orders_by_account_info(profile)

    # set fetch status with expire time
    mc.set(MC_FETCH_ACCOUNT_STATUS_BY_USER.format(user_id=profile.account_id),
           True)
    return profile.person_account_info
Ejemplo n.º 6
0
 def close_time(self):
     return mc.get(self.close_time_key)
Ejemplo n.º 7
0
 def open_time(self):
     return mc.get(self.open_time_key)
Ejemplo n.º 8
0
 def is_enabled(self):
     return bool(mc.get(self.key))
Ejemplo n.º 9
0
def confirm_bind(uid, mobile):
    cached_mobile = mc.get(MC_BIND_MOBILE_BY_USER % uid)
    if mobile != cached_mobile:
        raise BindError(u'申请验证码与最终提交时的手机号不一致')
    mc.delete(MC_BIND_MOBILE_BY_USER % uid)
    return _confirm_bind(uid, mobile)
Ejemplo n.º 10
0
def get_access_token(app_id, app_secret):
    return mc.get(CACHE_ACCESS_TOKEN_KEY)
Ejemplo n.º 11
0
 def get(cls, secret):
     return mc.get(_MC_CAPTCHA_KEY % secret)
Ejemplo n.º 12
0
 def has_read(self, user_id):
     return mc.get(FUNDWEEKLY_READ_CACHE_KEY % (self.id, user_id))
Ejemplo n.º 13
0
def get_total_ins_children_count():
    """get total user count who buy children insurance"""
    return mc.get(MC_TOTAL_INSURANCE_USER_COUNT) or 1
Ejemplo n.º 14
0
 def _load_token(self):
     key = self._token_rds_key.format(self)
     data = mc.get(key)
     if data:
         return json.loads(data)
Ejemplo n.º 15
0
 def voucher(self):
     return mc.get(self.key)
Ejemplo n.º 16
0
def images(key):
    v = mc.get(key)
    r = Response(v, mimetype='image/jpeg')
    return r