本文整理汇总了Python中models.Post.pub方法的典型用法代码示例。如果您正苦于以下问题:Python Post.pub方法的具体用法?Python Post.pub怎么用?Python Post.pub使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Post
的用法示例。
在下文中一共展示了Post.pub方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: feed
# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import pub [as 别名]
def feed(request, name):
if name.startswith('tag-'):
qs = Post.pub().filter('topics = ', name[4:])
else:
qs = Post.pub()
feed = MyFeed(None,None).setup(qs,5).get_feed()
response = Response(mimetype=feed.mime_type)
feed.write(response.stream, 'utf-8')
return response
示例2: index
# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import pub [as 别名]
def index(request):
latest = Post.pub().fetch(5)
# latest.reverse()
ns = NutSettings()
template = ns.index_layout
if template:
template = 'nut:layout/%s' % template
else:
template = 'app:articles/index.html'
return render_template(template, posts=latest)
latest = Post.pub().get()
if latest:
return redirect(quote((u'/%s' % latest.lookup).encode('utf-8')), 301)
return render_template('app/empty.html')
示例3: list
# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import pub [as 别名]
def list(request):
from logging import info
from datetime import datetime
if request.method == 'POST':
handle_backup(request.files.get('backup'))
pub_bm, upc_bm, unp_bm = None, None, None
if request.args.get('list','') == 'published':
pub_bm = request.args.get('bookmark', None)
elif request.args.get('list','') == 'upcoming':
upc_bm = request.args.get('bookmark', None)
elif request.args.get('list','') == 'unpublished':
unp_bm = request.args.get('bookmark', None)
pub_prev, pub, pub_next = pager(Post.pub(),
lambda bm: Post.pub().filter('sort_key <', bm),
lambda bm: Post.rpub().filter('sort_key >', bm),
bookmark=pub_bm)
upc_prev, upc, upc_next = pager(Post.upcoming(),
lambda bm: Post.upcoming()\
.filter('sort_key <', bm),
lambda bm: Post.rupcoming()\
.filter('sort_key >', bm),
bookmark=upc_bm)
unp_prev, unp, unp_next = pager(Post.unpub(),
lambda bm: Post.unpub()\
.filter('sort_key <', bm),
lambda bm: Post.runpub()\
.filter('sort_key >', bm),
bookmark=unp_bm)
return render_template('app:articles/list.html',
unpublished_prev = unp_prev,
unpublished = unp,
unpublished_next = unp_next,
upcoming_prev = upc_prev,
upcoming = upc,
upcoming_next = upc_next,
published_prev = pub_prev,
published = pub,
published_next = pub_next)
示例4: topic
# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import pub [as 别名]
def topic(request, tag):
qs = Post.pub()
rqs = Post.rpub()
if tag is not None:
qs = qs.filter('topics = ', tag)
rqs = rqs.filter('topics = ', tag)
prev, posts, next = pager(qs,
lambda bm: qs.filter('sort_key <', bm),
lambda bm: rqs.filter('sort_key >', bm),
bookmark=request.args.get('bookmark', None))
ns = NutSettings()
template = ns.archive_layout
if template:
template = 'nut:layout/%s' % template
else:
template = 'app:articles/archive.html'
return render_template(template,
prev=prev, next=next,
posts = posts,
tag=tag)
示例5: latest
# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import pub [as 别名]
def latest(n=5):
items = Post.pub().fetch(n)
#items.reverse()
return items