当前位置: 首页>>代码示例>>Python>>正文


Python Status.gets方法代码示例

本文整理汇总了Python中past.model.status.Status.gets方法的典型用法代码示例。如果您正苦于以下问题:Python Status.gets方法的具体用法?Python Status.gets怎么用?Python Status.gets使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在past.model.status.Status的用法示例。


在下文中一共展示了Status.gets方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: send_today_in_history

# 需要导入模块: from past.model.status import Status [as 别名]
# 或者: from past.model.status.Status import gets [as 别名]
def send_today_in_history(user_id):
    u = User.get(user_id)
    if not u:
        return

    setting = u.get_profile_item("email_remind_today_in_history")
    if setting == 'N':
        print '---user %s does not like to receive remind mail' % u.id
        return

    email = u.get_email()
    if not email:
        print '---- user %s no email' % u.id
        return
    
    yesterday_ids = get_status_ids_yesterday(u.id, 
            day=(datetime.datetime.now() - datetime.timedelta(days=1)).strftime("%Y-%m-%d"))
    status_of_yesterday = Status.gets(yesterday_ids)

    history_ids = get_status_ids_today_in_history(u.id, 
            day=datetime.datetime.now().strftime("%Y-%m-%d"))
    status_of_today_in_history = Status.gets(history_ids)

    intros = [u.get_thirdparty_profile(x).get("intro") for x in config.OPENID_TYPE_DICT.values()]
    intros = filter(None, intros)
    
    history_ids = get_status_ids_today_in_history(u.id, 
            day=datetime.datetime.now().strftime("%Y-%m-%d"))
    d = {}
    for s in Status.gets(history_ids):
        t = s.create_time.strftime("%Y-%m-%d")
        if d.has_key(t):
            d[t].append(s)
        else:
            d[t] = [s]
    status_of_today_in_history = d
    from past.consts import YESTERDAY


    if not (status_of_yesterday or status_of_today_in_history):
        print '--- user %s has no status in history' % u.id
        return

    from jinja2 import Environment, PackageLoader
    env = Environment(loader=PackageLoader('past', 'templates'))
    env.filters['wrap_long_line'] = wrap_long_line
    env.filters['nl2br'] = filters.nl2br
    env.filters['clear_html_element'] = clear_html_element
    t = env.get_template('mail.html')
    m = t.module


    html = m.status_in_past(status_of_yesterday, status_of_today_in_history, YESTERDAY, config, intros)
    html = html.encode("utf8")

    subject = '''来自thepast.me的提醒 %s''' % datetime.datetime.now().strftime("%Y-%m-%d")
    text = ''
    
    print '--- send reminding to %s %s' %(user_id, email)
    send_mail(["%s" % email], "Today of The Past<[email protected]>", subject, text, html, files=[], server="localhost")
开发者ID:MistShi,项目名称:thepast,代码行数:62,代码来源:send_reminding.py

示例2: user_more_by_domain

# 需要导入模块: from past.model.status import Status [as 别名]
# 或者: from past.model.status.Status import gets [as 别名]
def user_more_by_domain(uid):
    u = User.get(uid)
    if not u:
        abort(404, "no such user")

    r = check_access_user(u)
    if r:
        abort(400, "no priv to access")

    ids = Status.get_ids(user_id=u.id, start=g.start, limit=g.count, cate=g.cate)
    status_list = Status.gets(ids)
    if g.user and g.user.id == uid:
        pass
    elif g.user and g.user.id != uid:
        status_list = [x for x in status_list if x.privacy() != consts.STATUS_PRIVACY_PRIVATE]
    elif not g.user:
        status_list = [x for x in status_list if x.privacy() == consts.STATUS_PRIVACY_PUBLIC]
        
    status_list  = statuses_timelize(status_list)
    intros = [u.get_thirdparty_profile(x).get("intro") for x in config.OPENID_TYPE_DICT.values()]
    intros = filter(None, intros)

    if g.user:
        sync_list = get_sync_list(g.user)
    else:
        sync_list = []

    now = datetime.datetime.now().strftime("%Y年%m月%d日 %H:%M:%S")
    return render_template("v2/user_more.html", user=u, intros=intros, 
            status_list=status_list, config=config, sync_list=sync_list, 
            now = now)
开发者ID:HengeSense,项目名称:thepast,代码行数:33,代码来源:user_past.py

示例3: generate_pdf

# 需要导入模块: from past.model.status import Status [as 别名]
# 或者: from past.model.status.Status import gets [as 别名]
def generate_pdf(filename, uid, start, count, cate=None, with_head=True, capacity=50*1024):

    #########Set FONT################
    from xhtml2pdf.default import DEFAULT_FONT
    from xhtml2pdf.document import pisaDocument
    from reportlab.pdfbase import pdfmetrics
    from reportlab.pdfbase.ttfonts import TTFont

    pdfmetrics.registerFont(TTFont('zhfont', os.path.join(app.root_path, 'static/font/yahei-consolas.ttf')))
    DEFAULT_FONT["helvetica"] = "zhfont"
    css = open(os.path.join(app.root_path, "static/css/pdf.css")).read()

    #result = StringIO.StringIO()
    full_file_name = get_pdf_full_filename(filename)
    if not full_file_name:
        return None
    result = open(full_file_name, 'wb', 1024*1000)

    user = User.get(uid)
    if not user:
        return None

    # get status
    ids = Status.get_ids(user_id=uid, start=start, limit=count, cate=cate)
    status_list = Status.gets(ids)
    _html = render(user, status_list, with_head)
    _pdf = pisaDocument(_html, result, default_css=css, link_callback=link_callback, capacity=capacity)
    result.close()

    if not _pdf.err:
        return full_file_name
    else:
        return None
开发者ID:funfunsay,项目名称:thepast,代码行数:35,代码来源:pdf.py

示例4: user

# 需要导入模块: from past.model.status import Status [as 别名]
# 或者: from past.model.status.Status import gets [as 别名]
def user(uid):
    u = User.get(uid)
    if not u:
        abort(404, "no such user")

    if g.user and g.user.id == u.id:
        return redirect(url_for("timeline"))
    
    if u.get_profile_item('user_privacy') == consts.USER_PRIVACY_PRIVATE:
        flash(u"由于该用户设置了仅自己可见的权限,所以,我们就看不到了", "tip")
        return redirect(url_for("timeline"))

    #TODO:增加可否查看其他用户的权限检查
    cate = request.args.get("cate", None)
    ids = Status.get_ids(user_id=u.id, start=g.start, limit=g.count, cate=g.cate)
    status_list = Status.gets(ids)
    status_list  = statuses_timelize(status_list)
    if status_list:
        ##XXX:暂时去除了个人关键字的功能
        #tags_list = [x[0] for x in get_keywords(u.id, 30)]
        tags_list = []
    else:
        tags_list = []
    intros = [u.get_thirdparty_profile(x).get("intro") for x in config.OPENID_TYPE_DICT.values()]
    intros = filter(None, intros)
    return render_template("timeline.html", user=u, unbinded=[], 
            tags_list=tags_list, intros=intros, status_list=status_list, config=config)
开发者ID:dianso,项目名称:thepast,代码行数:29,代码来源:timelines.py

示例5: user_by_domain

# 需要导入模块: from past.model.status import Status [as 别名]
# 或者: from past.model.status.Status import gets [as 别名]
def user_by_domain(uid):
    u = User.get(uid)
    if not u:
        abort(404, "no such user")

    r = check_access_user(u)
    if r:
        flash(r[1].decode("utf8"), "tip")
        return redirect(url_for("home"))

    ids = Status.get_ids(user_id=u.id, start=g.start, limit=g.count, cate=g.cate)
    status_list = Status.gets(ids)
    if g.user and g.user.id == uid:
        pass
    elif g.user and g.user.id != uid:
        status_list = [x for x in status_list if x.privacy() != consts.STATUS_PRIVACY_PRIVATE]
    elif not g.user:
        status_list = [x for x in status_list if x.privacy() == consts.STATUS_PRIVACY_PUBLIC]
        
    status_list  = statuses_timelize(status_list)
    tags_list = []
    intros = [u.get_thirdparty_profile(x).get("intro") for x in config.OPENID_TYPE_DICT.values()]
    intros = filter(None, intros)

    if g.user:
        sync_list = get_sync_list(g.user)
    else:
        sync_list = []

    return render_template("timeline.html", user=u, unbinded=[], 
            tags_list=tags_list, intros=intros, 
            status_list=status_list, config=config, sync_list=sync_list)
开发者ID:loosky,项目名称:thepast,代码行数:34,代码来源:timelines.py

示例6: index

# 需要导入模块: from past.model.status import Status [as 别名]
# 或者: from past.model.status.Status import gets [as 别名]
def index():
    if not g.user:
        return redirect(url_for("user_explore"))

    ids = Status.get_ids(user_id=g.user.id, start=g.start, limit=g.count, cate=g.cate)
    status_list = Status.gets(ids)
    return render_template("timeline.html", user=g.user, status_list=status_list, config=config)
开发者ID:perryhau,项目名称:thepast,代码行数:9,代码来源:views.py

示例7: home

# 需要导入模块: from past.model.status import Status [as 别名]
# 或者: from past.model.status.Status import gets [as 别名]
def home():
    user_ids = User.get_ids(limit=10000)

    user = None
    i = 0
    while i <= 3:
        random_uid = random.choice(user_ids)
        user = User.get(random_uid)
        r = check_access_user(user)
        if not r:
            break
        i+=1

    if user:
        history_ids = Status.get_ids(user.id, start=0, limit=20)
        status_list = Status.gets(history_ids)
        status_list  = statuses_timelize(status_list)
        intros = [user.get_thirdparty_profile(x).get("intro") for x in config.OPENID_TYPE_DICT.values()]
        intros = filter(None, intros)
    else:
        status_list = []
        intros = []

    if g.user:
        sync_list = get_sync_list(g.user)
    else:
        sync_list = []

    d = defaultdict(list)
    for x in status_list:
        t = x.create_time.strftime("%Y年%m月%d日")
        d[t].append(x)
    history_status = d

    return render_template("v2/explore.html", **locals())
开发者ID:HengeSense,项目名称:thepast,代码行数:37,代码来源:user_past.py

示例8: past

# 需要导入模块: from past.model.status import Status [as 别名]
# 或者: from past.model.status.Status import gets [as 别名]
def past():
    intros = [g.user.get_thirdparty_profile(x).get("intro") for x in config.OPENID_TYPE_DICT.values()]
    intros = filter(None, intros)
    
    yesterday_ids = get_status_ids_yesterday(g.user.id)
    status_of_yesterday = Status.gets(yesterday_ids)

    history_ids = get_status_ids_today_in_history(g.user.id)
    d = {}
    for s in Status.gets(history_ids):
        t = s.create_time.strftime("%Y-%m-%d")
        if d.has_key(t):
            d[t].append(s)
        else:
            d[t] = [s]
    status_of_today_in_history = d
    from past.consts import YESTERDAY

    return render_template("past.html", **locals())
开发者ID:yanghuzhi,项目名称:thepast,代码行数:21,代码来源:views.py

示例9: timeline

# 需要导入模块: from past.model.status import Status [as 别名]
# 或者: from past.model.status.Status import gets [as 别名]
def timeline():
    ids = Status.get_ids(user_id=g.user.id, start=g.start, limit=g.count, cate=g.cate)
    status_list = Status.gets(ids)
    status_list  = statuses_timelize(status_list)
    if status_list:
        tags_list = [x[0] for x in get_keywords(g.user.id, 30)]
    else:
        tags_list = []
    intros = [g.user.get_thirdparty_profile(x).get("intro") for x in config.OPENID_TYPE_DICT.values()]
    intros = filter(None, intros)
    return render_template("timeline.html", user=g.user, tags_list=tags_list,
            intros=intros, status_list=status_list, config=config)
开发者ID:funfunsay,项目名称:thepast,代码行数:14,代码来源:timelines.py

示例10: send_yesterday

# 需要导入模块: from past.model.status import Status [as 别名]
# 或者: from past.model.status.Status import gets [as 别名]
def send_yesterday(user_id, now=None):
    if not now:
        now = datetime.datetime.now()

    u = User.get(user_id)
    if not u:
        return

    setting = u.get_profile_item("email_remind_today_in_history")
    if setting == "N":
        print "---user %s does not like to receive remind mail" % u.id
        return

    email = u.get_email()
    if not email:
        print "---- user %s no email" % u.id
        return

    yesterday_ids = get_status_ids_yesterday(u.id, now)
    status_of_yesterday = Status.gets(yesterday_ids)

    intros = [u.get_thirdparty_profile(x).get("intro") for x in config.OPENID_TYPE_DICT.values()]
    intros = filter(None, intros)

    from past.consts import YESTERDAY

    if not status_of_yesterday:
        print "--- user %s has no status in yesterday" % u.id
        return

    from jinja2 import Environment, PackageLoader

    env = Environment(loader=PackageLoader("past", "templates"))
    env.filters["wrap_long_line"] = wrap_long_line
    env.filters["nl2br"] = filters.nl2br
    env.filters["stream_time"] = filters.stream_time
    env.filters["clear_html_element"] = clear_html_element
    t = env.get_template("mail.html")
    m = t.module

    if now:
        y = (now - datetime.timedelta(days=1)).strftime("%Y-%m-%d")
    else:
        y = YESTERDAY
    html = m.status_in_past(status_of_yesterday, None, y, config, intros)
    html = html.encode("utf8")

    subject = """thepast.me|整理自己的故事 %s""" % now.strftime("%Y-%m-%d")
    text = ""

    print "--- send reminding to %s %s" % (user_id, email)
    send_mail(["%s" % email], "thepast<[email protected]>", subject, text, html)
开发者ID:Jeffwan,项目名称:thepast,代码行数:54,代码来源:send_reminding.py

示例11: user

# 需要导入模块: from past.model.status import Status [as 别名]
# 或者: from past.model.status.Status import gets [as 别名]
def user(uid):
    u = User.get(uid)
    if not u:
        abort(404, "no such user")

    if g.user and g.user.id == u.id:
        return redirect(url_for("index"))
    
    #TODO:增加可否查看其他用户的权限检查
    cate = request.args.get("cate", None)
    ids = Status.get_ids(user_id=u.id, start=g.start, limit=g.count, cate=g.cate)
    status_list = Status.gets(ids)
    return render_template("timeline.html", user=u, status_list=status_list, config=config)
开发者ID:perryhau,项目名称:thepast,代码行数:15,代码来源:views.py

示例12: user

# 需要导入模块: from past.model.status import Status [as 别名]
# 或者: from past.model.status.Status import gets [as 别名]
def user(uid):
    u = User.get(uid)
    if not u:
        abort(404, "no such user")

    if g.user and g.user.id == u.id:
        return redirect(url_for("timeline"))

    # TODO:增加可否查看其他用户的权限检查
    cate = request.args.get("cate", None)
    ids = Status.get_ids(user_id=u.id, start=g.start, limit=g.count, cate=g.cate)
    status_list = Status.gets(ids)
    status_list = statuses_timelize(status_list)
    unbinded = list(set(config.OPENID_TYPE_DICT.values()) - set([ua.type for ua in g.user.get_alias()]))
    tmp = {}
    for k, v in config.OPENID_TYPE_DICT.items():
        tmp[v] = k
    unbinded = [[x, tmp[x], config.OPENID_TYPE_NAME_DICT[x]] for x in unbinded]
    return render_template("timeline.html", user=u, unbinded=unbinded, status_list=status_list, config=config)
开发者ID:puzzlega,项目名称:thepast,代码行数:21,代码来源:views.py

示例13: user

# 需要导入模块: from past.model.status import Status [as 别名]
# 或者: from past.model.status.Status import gets [as 别名]
def user(uid):
    u = User.get(uid)
    if not u:
        abort(404, "no such user")

    if g.user and g.user.id == u.id:
        return redirect(url_for("timeline"))
    
    #TODO:增加可否查看其他用户的权限检查
    cate = request.args.get("cate", None)
    ids = Status.get_ids(user_id=u.id, start=g.start, limit=g.count, cate=g.cate)
    status_list = Status.gets(ids)
    status_list  = statuses_timelize(status_list)
    if status_list:
        tags_list = [x[0] for x in get_keywords(u.id, 30)]
    else:
        tags_list = []
    intros = [u.get_thirdparty_profile(x).get("intro") for x in config.OPENID_TYPE_DICT.values()]
    intros = filter(None, intros)
    return render_template("timeline.html", user=u, unbinded=[], 
            tags_list=tags_list, intros=intros, status_list=status_list, config=config)
开发者ID:funfunsay,项目名称:thepast,代码行数:23,代码来源:timelines.py

示例14: user_past

# 需要导入模块: from past.model.status import Status [as 别名]
# 或者: from past.model.status.Status import gets [as 别名]
def user_past(uid):
    user = User.get(uid)
    if not user:
        abort(404, "no such user")

    r = check_access_user(user)
    if r:
        flash(r[1].decode("utf8"), "tip")
        return redirect("/")

    try:
        now = datetime.datetime.strptime(request.args.get("now"), "%Y-%m-%d")
    except:
        now = datetime.datetime.now()

    history_ids = get_status_ids_today_in_history(user.id, now) 
    status_list = Status.gets(history_ids)
    if g.user and g.user.id == uid:
        pass
    elif g.user and g.user.id != uid:
        status_list = [x for x in status_list if x.privacy() != consts.STATUS_PRIVACY_PRIVATE]
    elif not g.user:
        status_list = [x for x in status_list if x.privacy() == consts.STATUS_PRIVACY_PUBLIC]

    status_list  = statuses_timelize(status_list)
    if g.user:
        sync_list = get_sync_list(g.user)
    else:
        sync_list = []

    intros = [user.get_thirdparty_profile(x).get("intro") for x in config.OPENID_TYPE_DICT.values()]
    intros = filter(None, intros)

    d = defaultdict(list)
    for x in status_list:
        t = x.create_time.strftime("%Y年%m月%d日")
        d[t].append(x)
    history_status = d

    return render_template("v2/user_past.html", **locals())
开发者ID:EdwinHi,项目名称:thepast,代码行数:42,代码来源:user_past.py

示例15: past

# 需要导入模块: from past.model.status import Status [as 别名]
# 或者: from past.model.status.Status import gets [as 别名]
def past():
    intros = [g.user.get_thirdparty_profile(x).get("intro") for x in config.OPENID_TYPE_DICT.values()]
    intros = filter(None, intros)
    
    try:
        now = datetime.datetime.strptime(request.args.get("now"), "%Y-%m-%d")
    except:
        now = datetime.datetime.now()

    history_ids = get_status_ids_today_in_history(g.user.id, now) 
    status_list = Status.gets(history_ids)
    status_list  = statuses_timelize(status_list)

    sync_list = get_sync_list(g.user)

    d = defaultdict(list)
    for x in status_list:
        t = x.create_time.strftime("%Y年%m月%d日")
        d[t].append(x)
    history_status = d
    
    return render_template("past.html", **locals())
开发者ID:daqing15,项目名称:thepast,代码行数:24,代码来源:views.py


注:本文中的past.model.status.Status.gets方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。