本文整理汇总了Python中past.model.status.Status.get_ids方法的典型用法代码示例。如果您正苦于以下问题:Python Status.get_ids方法的具体用法?Python Status.get_ids怎么用?Python Status.get_ids使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类past.model.status.Status
的用法示例。
在下文中一共展示了Status.get_ids方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: home
# 需要导入模块: from past.model.status import Status [as 别名]
# 或者: from past.model.status.Status import get_ids [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())
示例2: generate_pdf
# 需要导入模块: from past.model.status import Status [as 别名]
# 或者: from past.model.status.Status import get_ids [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
示例3: user_by_domain
# 需要导入模块: from past.model.status import Status [as 别名]
# 或者: from past.model.status.Status import get_ids [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)
示例4: user
# 需要导入模块: from past.model.status import Status [as 别名]
# 或者: from past.model.status.Status import get_ids [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)
示例5: index
# 需要导入模块: from past.model.status import Status [as 别名]
# 或者: from past.model.status.Status import get_ids [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)
示例6: user_more_by_domain
# 需要导入模块: from past.model.status import Status [as 别名]
# 或者: from past.model.status.Status import get_ids [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)
示例7: timeline
# 需要导入模块: from past.model.status import Status [as 别名]
# 或者: from past.model.status.Status import get_ids [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)
示例8: user
# 需要导入模块: from past.model.status import Status [as 别名]
# 或者: from past.model.status.Status import get_ids [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)
示例9: user
# 需要导入模块: from past.model.status import Status [as 别名]
# 或者: from past.model.status.Status import get_ids [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)
示例10: user
# 需要导入模块: from past.model.status import Status [as 别名]
# 或者: from past.model.status.Status import get_ids [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)
示例11: timeline_json
# 需要导入模块: from past.model.status import Status [as 别名]
# 或者: from past.model.status.Status import get_ids [as 别名]
def timeline_json(uid, start):
limit = 50
start = int(start)
u = User.get(uid)
if not u:
abort(404, "no such user")
r = check_access_user(u)
if r:
abort(r[0], r[1])
ids = Status.get_ids(user_id=u.id, start=start, limit=limit, 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]
if not status_list:
return json_encode({})
date = []
for s in status_list:
headline = s.title or s.summary or ""
text = s.text or ""
data = s.get_data()
images = data and data.get_images() or []
uri = s.get_origin_uri()
if uri:
headline = '<a href="%s" target="_blank">%s</a>' % (uri and uri[1], headline)
if not (headline or text or images):
continue
t = s.create_time
if s.category in [config.CATE_DOUBAN_STATUS, config.CATE_SINA_STATUS]:
re_tweet = s.get_retweeted_data()
re_images = re_tweet and re_tweet.get_images() or []
images.extend(re_images)
text = re_tweet and re_tweet.get_content() or ""
if s.category in [config.CATE_DOUBAN_STATUS]:
atts = data and data.get_attachments()
if atts:
for att in atts:
text += att.get_title() + "\n" + att.get_description()
if s.category in [config.CATE_QQWEIBO_STATUS]:
text = s.get_retweeted_data() or ""
if s.category in [config.CATE_WORDPRESS_POST, config.CATE_THEPAST_NOTE, config.CATE_RENREN_BLOG]:
uri = s.get_origin_uri()
headline = '<a href="%s" target="_blank">%s</a>' % (uri and uri[1], s.title)
text = s.text or ""
if s.category in [config.CATE_RENREN_STATUS, config.CATE_RENREN_PHOTO, config.CATE_RENREN_ALBUM]:
headline = s.title
text = s.text or ""
tmp = {
"startDate": t.strftime("%Y,%m,%d,%H,%M,%S"),
"headline": headline,
"text": text,
"asset": {"media": images and images[0], "credit": "", "caption": ""},
}
try:
json_encode(tmp)
date.append(tmp)
except:
pass
if date:
more = {
"startDate": (status_list[-1].create_time - timedelta(0, 0, 1)).strftime("%Y,%m,%d,%H,%M,%S"),
"headline": '<a href="/visual/%s?start=%s">查看更早的内容...</a>' % (u.id, start + limit),
"text": "",
"asset": {"media": "", "credit": "", "caption": ""},
}
date.append(more)
if start == 0:
cover = {
"startDate": datetime.now().strftime("%Y,%m,%d,%H,%M,%S"),
"headline": "The past of you",
"text": "Storytelling about yourself...",
"asset": {"media": "", "credit": "", "caption": ""},
}
date.insert(0, cover)
json_data = {
"timeline": {
"headline": "The past of you",
"type": "default",
"startDate": date[0]["startDate"],
"text": "Storytelling about yourself...",
"asset": {"media": "", "credit": "", "caption": ""},
#.........这里部分代码省略.........
示例12: timeline
# 需要导入模块: from past.model.status import Status [as 别名]
# 或者: from past.model.status.Status import get_ids [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)
return render_template("timeline.html", user=g.user, status_list=status_list, config=config)
示例13: timeline_json
# 需要导入模块: from past.model.status import Status [as 别名]
# 或者: from past.model.status.Status import get_ids [as 别名]
def timeline_json(uid):
limit = 50
u = User.get(uid)
if not u:
abort(404, "no such user")
if uid != g.user.id and u.get_profile_item('user_privacy') == consts.USER_PRIVACY_PRIVATE:
abort(403, "not allowed")
cate = request.args.get("cate", None)
ids = Status.get_ids(user_id=u.id,
start=g.start, limit=limit, cate=g.cate)
ids = ids[::-1]
status_list = Status.gets(ids)
if not status_list:
return json_encode({})
date = []
for s in status_list:
headline = s.summary or ''
text = ''
images = s.get_data().get_images() or []
if not (headline or text):
continue
t = s.create_time
if s.category in [config.CATE_DOUBAN_STATUS, config.CATE_SINA_STATUS]:
re_tweet = s.get_retweeted_data()
re_images = re_tweet and re_tweet.get_images() or []
images.extend(re_images)
text = re_tweet and re_tweet.get_content() or ''
if s.category in [config.CATE_QQWEIBO_STATUS]:
text = s.get_retweeted_data() or ''
if s.category in [config.CATE_WORDPRESS_POST]:
uri = s.get_origin_uri()
headline = '<a href="%s" target="_blank">%s</a>' % (uri and uri[1], s.title)
text = s.text or ''
tmp = {
'startDate': t.strftime("%Y,%m,%d,%H,%M,%S"),
'headline': headline,
'text': text,
'asset': {
'media': images and images[0],
'credit': '',
'caption': ''
},
}
try:
json_encode(tmp)
date.append(tmp)
except:
pass
if date:
tmp = {
'startDate': datetime.now().strftime("%Y,%m,%d,%H,%M,%S"),
'headline': '<a href="/user/%s/visual?start=%s">查看更早的内容...</a>' % (u.id, g.start+limit),
'text': '',
'asset': {
'media': '', 'credit': '', 'caption': ''
},
}
date.insert(0, tmp)
json_data = {
'timeline':
{
'headline': 'The past of you',
'type': 'default',
'startDate': date[1]['startDate'],
'text': 'Storytelling about yourself...',
'asset':{
'media': '',
'credit': '',
'caption': ''
},
'date':date
}
}
return json_encode(json_data)
示例14: pdf
# 需要导入模块: from past.model.status import Status [as 别名]
# 或者: from past.model.status.Status import get_ids [as 别名]
def pdf(uid):
from xhtml2pdf.default import DEFAULT_FONT
from xhtml2pdf.document import pisaDocument
#########Set FONT################
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()
user = User.get(uid)
if not g.user:
##匿名用户暂时只能看我的作为演示
g.count = min(25, g.count)
user = User.get(config.MY_USER_ID)
else:
if g.user.id == user.id:
if g.count < 60:
g.count = 60
g.count = min(100, g.count)
else:
##登录用户只能生成别人的25条
g.count = min(25, g.count)
# get status
ids = Status.get_ids(user_id=uid, start=g.start, limit=g.count, cate=g.cate)
status_list = Status.gets(ids)
_html = u"""<html> <body>
<div id="Top">
<img src="%s"/> The Past of Me | 个人杂志计划 %s CopyRight©%s
<br/>
</div>
<br/> <br/>
<div class="box">
""" %(os.path.join(app.root_path, "static/img/logo.png"),
datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"), user.name)
for s in status_list:
title = s.title
create_time = s.create_time
from_ = ''
if s.category == config.CATE_DOUBAN_MINIBLOG:
from_ = u'<a href="' + config.DOUBAN_MINIBLOG %(s.origin_user_id, s.origin_id) + u'class="node">From:豆瓣广播</a>'
elif s.category == config.CATE_DOUBAN_NOTE:
from_ = u'<a href="' + config.DOUBAN_NOTE %(s.origin_id,) + u'class="node">From:豆瓣日记</a>'
elif s.category == config.CATE_SINA_STATUS:
from_ = u'<a href="' + config.WEIBO_STATUS %(s.origin_id) + u'class="node">From:新浪微博</a>'
elif s.category == config.CATE_TWITTER_STATUS:
from_ = u'<a href="' + config.TWITTER_STATUS %(s.origin_id) + u'class="node">From:twitter</a>'
text = s.text
retweeted_text = ''
img = ''
if s.category == config.CATE_DOUBAN_MINIBLOG:
##miniblog不显示title
title = ''
links = s.get_data().get_links()
if links and links.get("image"):
img = links.get("image")
elif s.category == config.CATE_SINA_STATUS:
retweeted = s.get_data().get_retweeted_status()
re_mid_pic = retweeted and retweeted.get_middle_pic() or ''
middle_pic = s.get_data().get_middle_pic()
if retweeted:
retweeted_text = retweeted.get_user().get_nickname() + ": " + retweeted.get_content()
if re_mid_pic or middle_pic:
img = re_mid_pic or middle_pic
_html += """ <hr/> <div class="cell">"""
if title:
title = wrap_long_line(title)
_html += """<div class="bigger">%s</div>""" %title
if text:
text = wrap_long_line(text)
if s.category == config.CATE_DOUBAN_NOTE:
text = filters.nl2br(text)
_html += """<div class="content">%s</div>""" %text
if retweeted_text:
retweeted_text = wrap_long_line(retweeted_text)
_html += """<div class='tip'><span class="fade">%s</span></div>""" %retweeted_text
if img:
_html += """<img src=%s></img>""" %img
_html += """<div class="fade">%s %s</div>""" %(from_, create_time)
_html += """ </div> <body> </html> """
_pdf = pisaDocument(_html, result, default_css=css, link_callback=link_callback)
if not _pdf.err:
result.seek(0)
pdf_filename = "thepast.me_pdf_%s%s.pdf" %(user.id, randbytes(6))
save_pdf(result.getvalue(), pdf_filename)
#resp = make_response(result.getvalue())
#resp.headers["content-type"] = "application/pdf"
resp = make_response()
#.........这里部分代码省略.........
示例15: timeline_json
# 需要导入模块: from past.model.status import Status [as 别名]
# 或者: from past.model.status.Status import get_ids [as 别名]
def timeline_json(uid, start):
limit = 50
start = int(start)
u = User.get(uid)
if not u:
abort(404, "no such user")
r = check_access_user(u)
if r:
abort(r[0], r[1])
ids = Status.get_ids(user_id=u.id,
start=start, limit=limit, 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]
if not status_list:
return json_encode({})
date = []
for s in status_list:
headline = s.summary or ''
text = ''
images = s.get_data().get_images() or []
if not (headline or text):
continue
t = s.create_time
if s.category in [config.CATE_DOUBAN_STATUS, config.CATE_SINA_STATUS]:
re_tweet = s.get_retweeted_data()
re_images = re_tweet and re_tweet.get_images() or []
images.extend(re_images)
text = re_tweet and re_tweet.get_content() or ''
if s.category in [config.CATE_DOUBAN_STATUS]:
atts = s.get_data() and s.get_data().get_attachments()
if atts:
for att in atts:
text += att.get_title() + "\n" + att.get_description()
if s.category in [config.CATE_QQWEIBO_STATUS]:
text = s.get_retweeted_data() or ''
if s.category in [config.CATE_WORDPRESS_POST]:
uri = s.get_origin_uri()
headline = '<a href="%s" target="_blank">%s</a>' % (uri and uri[1], s.title)
text = s.text or ''
if s.category in [config.CATE_THEPAST_NOTE]:
uri = s.get_origin_uri()
headline = '<a href="%s" target="_blank">%s</a>' % (uri and uri[1], s.title)
text = s.text or ''
tmp = {
'startDate': t.strftime("%Y,%m,%d,%H,%M,%S"),
'headline': headline,
'text': text,
'asset': {
'media': images and images[0],
'credit': '',
'caption': ''
},
}
try:
json_encode(tmp)
date.append(tmp)
except:
pass
if date:
more = {
'startDate': (status_list[-1].create_time - timedelta(0, 0, 1)).strftime("%Y,%m,%d,%H,%M,%S"),
'headline': '<a href="/visual/%s?start=%s">查看更早的内容...</a>' % (u.id, start+limit),
'text': '',
'asset': {
'media': '', 'credit': '', 'caption': ''
},
}
date.append(more)
if start == 0:
cover = {
'startDate': datetime.now().strftime("%Y,%m,%d,%H,%M,%S"),
'headline': 'The past of you',
'text': 'Storytelling about yourself...',
'asset': {
'media': '', 'credit': '', 'caption': ''
},
}
date.insert(0, cover)
json_data = {
#.........这里部分代码省略.........