Beispiel #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
Beispiel #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
Beispiel #3
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
Beispiel #4
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
Beispiel #5
0
 def disable(self):
     mc.set(self.key, False)
Beispiel #6
0
 def enable(self):
     mc.set(self.key, True)
Beispiel #7
0
def request_bind(uid, mobile, is_send_sms=True):
    mc.set(MC_BIND_MOBILE_BY_USER % uid, mobile)
    if is_send_sms:
        sms = ShortMessage.create(mobile, mobile_bind_sms, user_id=uid)
        sms.send()
Beispiel #8
0
def tokensetter(app_id, app_secret, access_token, expires_in):
    mc.set(CACHE_ACCESS_TOKEN_KEY, access_token)
    mc.expire(CACHE_ACCESS_TOKEN_KEY, expires_in)
Beispiel #9
0
 def generate(self, secret):
     image_io, code = self._gen()
     mc.set(_MC_CAPTCHA_KEY % secret, code)
     mc.expire(_MC_CAPTCHA_KEY % secret, self.expire)
     return image_io
Beispiel #10
0
def incr_user_count():
    mc.set(USER_COUNT_MC_KEY, get_user_count()+1)
Beispiel #11
0
def set_total_ins_children_count():
    """set total user count who buy children insurance"""
    mc.set(MC_TOTAL_INSURANCE_USER_COUNT, get_total_ins_children_count() + 1)
Beispiel #12
0
 def upload(self, data, mime_type, key=None):
     key = key or gen_salt(16)
     mc.set('%s:%s' % (self.bucket_name, key), data)
     return {}
Beispiel #13
0
 def _save_token(self, token):
     key = self._token_rds_key.format(self)
     data = json.dumps(token)
     mc.set(key, data)
     mc.expireat(key, int(token['expires_at']))
Beispiel #14
0
 def open_time(self, open_time):
     mc.set(self.open_time_key, open_time)
Beispiel #15
0
 def mark_as_read(self, user_id):
     mc.set(FUNDWEEKLY_READ_CACHE_KEY % (self.id, user_id), True)
Beispiel #16
0
 def close_time(self, close_time):
     mc.set(self.close_time_key, close_time)
Beispiel #17
0
 def voucher(self, base):
     mc.set(self.key, base)