Ejemplo n.º 1
0
 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
     self.text = json_decode(redis_conn.get(
             self.__class__.STATUS_REDIS_KEY % self.id))
     self.raw = json_decode(redis_conn.get(
             self.__class__.RAW_STATUS_REDIS_KEY % self.id))
     self.origin_user_id = UserAlias.get_by_user_and_type(self.user_id, self.site).alias
def move_user_profile():
    RAW_USER_REDIS_KEY = "/user/raw/%s" 

    cursor = db_conn.execute("select id from user order by id")
    rows = cursor.fetchall()
    cursor and cursor.close()
    for row in rows:
        print '--------user raw id:', row[0]
        sys.stdout.flush()
        r = redis_conn.get(RAW_USER_REDIS_KEY % row[0])
        if r:
            mongo_conn.set(RAW_USER_REDIS_KEY % row[0], r)
        r2 = redis_conn.get("/profile/%s" % row[0])
        if r2:
            mongo_conn.set("/profile/%s" % row[0], r2)
Ejemplo n.º 3
0
    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
        self.text = redis_conn.get(self.__class__.STATUS_REDIS_KEY % self.id)
        self.text = json_decode(self.text) if self.text else ""
        self.origin_user_id = UserAlias.get_by_user_and_type(self.user_id, self.site).alias
        if self.site == config.OPENID_TYPE_DICT[config.OPENID_TWITTER]:
            self.create_time += datetime.timedelta(seconds=8*3600)

        self.bare_text = self._generate_bare_text()
Ejemplo n.º 4
0
 def raw(self):
     _raw = redis_conn.get(Status.RAW_STATUS_REDIS_KEY % self.id)
     return json_decode(_raw) if _raw else ""
Ejemplo n.º 5
0
 def get_detail(self):
     k = self.__class__.kv_db_key_task % self.id
     d = redis_conn.get(k)
     d = json_decode(d) if d else {}
     return d
Ejemplo n.º 6
0
 def raw(self):
     _raw = redis_conn.get(User.RAW_USER_REDIS_KEY % self.id)
     return json_decode(_raw) if _raw else ""
Ejemplo n.º 7
0
 def get_profile(self):
     r = redis_conn.get('/profile/%s' %self.id)
     return json_decode(r) if r else {}