Exemplo n.º 1
0
import datetime
import hashlib
import re
from MySQLdb import IntegrityError

from past import config
from past.utils.escape import json_encode, json_decode, clear_html_element
from past.utils.logger import logging
from past.store import mongo_conn, mc, db_conn
from past.corelib.cache import cache, pcache, HALF_HOUR
from .user import UserAlias
from .data import DoubanMiniBlogData, DoubanNoteData, DoubanStatusData, \
        SinaWeiboStatusData, QQWeiboStatusData, TwitterStatusData

log = logging.getLogger(__file__)

class Status(object):
    
    STATUS_REDIS_KEY = "/status/text/%s"
    RAW_STATUS_REDIS_KEY = "/status/raw/%s"
    
    def __init__(self, id, user_id, origin_id, 
            create_time, site, category, title=""):
        self.id = str(id)
        self.user_id = str(user_id)
        self.origin_id = str(origin_id)
        self.create_time = create_time
        self.site = site
        self.category = category
        self.title = title
Exemplo n.º 2
0
import sys

sys.path.append("../")

from past.store import db_conn
from past.model.user import User
from past.model.status import Status
from past.model.kv import RawStatus
from past import consts
from past import config

from past.utils.logger import logging

log = logging.getLogger(__file__)

suicide_log = logging.getLogger(__file__)
suicide_log.addHandler(logging.FileHandler(config.SUICIDE_LOG))


def remove_user(uid, clear_status=True):
    user = User.get(uid)
    if not user:
        print "---no user:%s" % uid

    suicide_log.info("---- delete from user, uid=%s" % uid)
    db_conn.execute("delete from user where id=%s", uid)
    db_conn.commit()
    User._clear_cache(uid)

    if clear_status:
        cursor = db_conn.execute("select id from status where user_id=%s", uid)
Exemplo n.º 3
0
import urllib
import urlparse
from past import config
from past.utils.logger import logging
from past.utils.escape import json_decode
from past.utils import httplib2_request

from past.model.user import User, UserAlias, OAuth2Token
from past.model.data import DoubanUser
from past.model.data import DoubanNoteData, DoubanStatusData, DoubanMiniBlogData

from .oauth2 import OAuth2
from .error import OAuthError, OAuthLoginError, OAuthTokenExpiredError

log = logging.getLogger(__file__)


class Douban(OAuth2):

    authorize_uri = 'https://www.douban.com/service/auth2/auth'
    access_token_uri = 'https://www.douban.com/service/auth2/token'
    api_host = "https://api.douban.com"

    def __init__(self, alias=None, access_token=None, refresh_token=None):
        d = config.APIKEY_DICT[config.OPENID_DOUBAN]
        super(Douban, self).__init__(provider=config.OPENID_DOUBAN,
                                     apikey=d["key"],
                                     apikey_secret=d["secret"],
                                     redirect_uri=d["redirect_uri"],
                                     alias=alias,
Exemplo n.º 4
0
import sys
sys.path.append('../')

from past.store import db_conn
from past.model.user import User
from past.model.status import Status
from past.model.kv import RawStatus
from past import consts
from past import config

from past.utils.logger import logging
log = logging.getLogger(__file__)

suicide_log = logging.getLogger(__file__)
suicide_log.addHandler(logging.FileHandler(config.SUICIDE_LOG))


def remove_user(uid, clear_status=True):
    user = User.get(uid)
    if not user:
        print '---no user:%s' % uid

    suicide_log.info("---- delete from user, uid=%s" % uid)
    db_conn.execute("delete from user where id=%s", uid)
    db_conn.commit()
    User._clear_cache(uid)

    if clear_status:
        cursor = db_conn.execute("select id from status where user_id=%s", uid)
        if cursor:
            rows = cursor.fetchall()