# Path: config/setting.py

# 
# Path: model/user.py
# def check(name,info):
# def get_by_id(id):
# def fav_pages(user_id=None,show_private=False,per=5):
# def favs_of_page(page=1,per=5,user_id=0,show_private=False):
# def parse_data(name,info):
# def new_oauth_user(name,info):
# def update_oauth_userid(name,id,oauth_id):
# def update_access_token(name,id,token):
# def exist_oauth_user(name,info):
# def login_oauth_user(name,info):
# 
# Path: util/login.py
# def login(userid):
#     # 1. sha1(salt+ip+userid+now)
#     now=str(datetime.now())
#     userid=str(userid)
#     hash=sha1(salt+userid+now)
#     # 2. 储存hash id,userid,hash
#     db.insert("login",userid=userid,hash=hash,time=now,discard=0)
#     # 3. write cookie ua:sha1
#     web.setcookie('cu', hash, 3600*24*30)
#     return hash
# 
# Path: util/oauth.py
# class weibo(oauthbase):
# class douban(oauthbase):
#     def get_current_user_info(self,access_token):
#     def post(self,content):
#     def get_current_user_info(self,access_token):
#     def post(self,content):
# def createClientWithName(name,user=None):


import web
import requests
import traceback
import urllib
import json
from datetime import datetime
from config import setting
from model import user
from util import login
from util import oauth

        if page < 1:
            page = 1

        vars = {"id":id}

        where = "fav.userid=user.id and fav.pieceid=piece.id and user.id=$id"

        favs = db.select(["fav","piece","user"]
            ,what="avatar,piece.id,piece.content,fav.addtime"
            ,where=where
            ,vars=vars,limit=per
            ,offset=(page-1) * per
            ,order="addtime DESC")

        favs = list(favs)
        for item in favs:
            item["addtime"] = item["addtime"].strftime('%Y-%m-%d')

        return favs

class authuser:
    @common_check(post=["name","access_token"],need_login=False)
    def POST(self,ctx):
        name = ctx["post"]["name"]
        access_token = ctx["post"]["access_token"]


        ret_user = None
        client_token = None

# Path: config/setting.py

# 
# Path: model/user.py
# def check(name,info):
# def get_by_id(id):
# def fav_pages(user_id=None,show_private=False,per=5):
# def favs_of_page(page=1,per=5,user_id=0,show_private=False):
# def parse_data(name,info):
# def new_oauth_user(name,info):
# def update_oauth_userid(name,id,oauth_id):
# def update_access_token(name,id,token):
# def exist_oauth_user(name,info):
# def login_oauth_user(name,info):
# 
# Path: util/login.py
# def login(userid):
#     # 1. sha1(salt+ip+userid+now)
#     now=str(datetime.now())
#     userid=str(userid)
#     hash=sha1(salt+userid+now)
#     # 2. 储存hash id,userid,hash
#     db.insert("login",userid=userid,hash=hash,time=now,discard=0)
#     # 3. write cookie ua:sha1
#     web.setcookie('cu', hash, 3600*24*30)
#     return hash
# 
# Path: util/oauth.py
# class weibo(oauthbase):
# class douban(oauthbase):
#     def get_current_user_info(self,access_token):
#     def post(self,content):
#     def get_current_user_info(self,access_token):
#     def post(self,content):
# def createClientWithName(name,user=None):


# Path: controller/ajax.py
import web
import requests
import traceback
import urllib
import json
from datetime import datetime
from config import setting
from model import user
from util import login
from util import oauth


        if page < 1:
            page = 1

        vars = {"id":id}

        where = "fav.userid=user.id and fav.pieceid=piece.id and user.id=$id"

        favs = db.select(["fav","piece","user"]
            ,what="avatar,piece.id,piece.content,fav.addtime"
            ,where=where
            ,vars=vars,limit=per
            ,offset=(page-1) * per
            ,order="addtime DESC")

        favs = list(favs)
        for item in favs:
            item["addtime"] = item["addtime"].strftime('%Y-%m-%d')

        return favs

class authuser:
    @common_check(post=["name","access_token"],need_login=False)
    def POST(self,ctx):
        name = ctx["post"]["name"]
        access_token = ctx["post"]["access_token"]


        ret_user = None
        client_token = None

        cur_user = login.logged()