예제 #1
0
파일: urls.py 프로젝트: lixiangbest/jblog
def remove_blogtag(blog,remove):
    if not remove:
        return
    remove_string = "','".join(remove)
    s='delete from blogtag where blogtag.blog_id="%s" and blogtag.tag_id in (\'%s\')' % (blog.id,remove_string)
    logging.info('#########')
    logging.info(s)
    db.update(s)
    for tag_id in remove:
        tag = Tag.get(tag_id)
        tag_count_min(tag)
예제 #2
0
파일: urls.py 프로젝트: ZhQYuan/jblog
def remove_blogtag(blog, remove):
    if not remove:
        return
    remove_string = "','".join(remove)
    s = "delete from blogtag where blogtag.blog_id=\"%s\" and blogtag.tag_id in ('%s')" % (blog.id, remove_string)
    logging.info("#########")
    logging.info(s)
    db.update(s)
    for tag_id in remove:
        tag = Tag.get(tag_id)
        tag_count_min(tag)
예제 #3
0
def remove_blogtag(blog,remove):
    if not remove:
        return
    remove_string = "','".join(remove)
    s='delete from blogtag where blogtag.blog_id="%s" and blogtag.tag_id in (\'%s\')' % (blog.id,remove_string)
    logging.info('#########')
    logging.info(s)
    db.update(s)
    for tag_id in remove:
        tag = Tag.get(tag_id)
        tag_count_min(tag)
예제 #4
0
def callback():
    i = web.input()
    code = i.get("code", None)
    if code:
        # /callback?code=xxx
        client = APIClient(app_key=APP_KEY, app_secret=APP_SECRET)
        token = client.request_access_token(code, _CALLBACK_URL)
        logging.info("got access token: %s" % str(token))
        uid = token.uid
        kw = dict(access_token=token.access_token, expires_in=token.expires_in)
        # check for update:
        if 0 == db.update("user", where="uid=$uid", vars=dict(uid=uid), **kw):
            # create user:
            client.set_access_token(token.access_token, token.expires_in)
            user = client.get.users__show(uid=uid)
            kw["uid"] = uid
            kw["name"] = user.screen_name
            kw["gender"] = user.gender
            kw["province_code"] = user.province
            kw["city_code"] = user.city
            kw["image_url"] = user.profile_image_url
            db.insert("user", **kw)
        # make a cookie:
        web.setcookie("weibouser", _make_cookie(uid, token.access_token), int(token.expires_in - time.time()))
        raise web.found("/index")
예제 #5
0
파일: urls.py 프로젝트: alsotang/OPENTree0
 def save_access_token_to_db(self, uid, token, secret):
     kw = dict(oauth_token=token, oauth_token_secret=secret, join_time=str(datetime.now()))
     # check for update:
     if 0==db.update('account_info', where='user_id=$user_id', vars=dict(user_id=uid), **kw):
         db.insert('account_info', user_id=uid, oauth_token=token, oauth_token_secret=secret)
예제 #6
0
 def POST(self):
     for i in db.select('account_info'):
         self.client = APIClient(app_key=APP_KEY, app_secret=APP_SECRET, token=OAuthToken(oauth_token=i.oauth_token, oauth_token_secret=i.oauth_token_secret))
         if self.process_new_rts(i.rt_since_id):
             db.update('account_info', where = 'id = %s' % i.id, rt_since_id = self.since_id)