本文整理汇总了Python中model.Article.get_articles_by_latest方法的典型用法代码示例。如果您正苦于以下问题:Python Article.get_articles_by_latest方法的具体用法?Python Article.get_articles_by_latest怎么用?Python Article.get_articles_by_latest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.Article
的用法示例。
在下文中一共展示了Article.get_articles_by_latest方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: wx_get_latest_articles
# 需要导入模块: from model import Article [as 别名]
# 或者: from model.Article import get_articles_by_latest [as 别名]
def wx_get_latest_articles(self):
k = 'wx_latest'
v = getMc(k)
if v:
return v
posts = Article.get_articles_by_latest()
articles_msg = {'articles':[]}
for post in posts:
#slug = slugfy(post['title'])#yobin 20160718
slug = post['title']
desc = HTML_REG.sub('',post['content'].decode('utf-8')[:DESCRIPTION_CUT_WORDS].encode('utf-8'))
shorten_url = '%s/t/%s' % (BASE_URL, post['id'])
article = {
'title': slug,
'description':desc,
'picUrl':WX_DEFAULT_PIC,
'url':shorten_url,
}
# 插入文章
articles_msg['articles'].append(article)
article = {}
setMc(k,articles_msg)
return articles_msg
示例2: get_latest_articles
# 需要导入模块: from model import Article [as 别名]
# 或者: from model.Article import get_articles_by_latest [as 别名]
def get_latest_articles(self):
global MAX_ARTICLE
global PIC_URL
article_list = Article.get_articles_by_latest()
article_list_length = len(article_list)
count = (article_list_length < MAX_ARTICLE) and article_list_length or MAX_ARTICLE
if article_list:
# 构造图文消息
articles_msg = {'articles':[]}
for i in range(0,count):
article = {
'title': article_list[i].slug,
'description':article_list[i].description,
'picUrl':PIC_URL,
'url':article_list[i].absolute_url
}
# 插入文章
articles_msg['articles'].append(article)
article = {}
# 返回文章
return articles_msg