本文整理汇总了Python中models.comment.Comment.get_comments方法的典型用法代码示例。如果您正苦于以下问题:Python Comment.get_comments方法的具体用法?Python Comment.get_comments怎么用?Python Comment.get_comments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.comment.Comment
的用法示例。
在下文中一共展示了Comment.get_comments方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: blog_show
# 需要导入模块: from models.comment import Comment [as 别名]
# 或者: from models.comment.Comment import get_comments [as 别名]
def blog_show(blog_id):
blog = Blog.get(blog_id)
user = get_user()
if not user:
is_join = False
else:
is_join = blog.get_is_join(user.id)
comment_list = Comment.get_comments(blog_id)
return header_render('blog_show.html', blog=blog, comment_list = comment_list,
is_join = is_join)
示例2: get_memorial
# 需要导入模块: from models.comment import Comment [as 别名]
# 或者: from models.comment.Comment import get_comments [as 别名]
def get_memorial(url=None, user_id=None, create_if_none=True, init=False):
from models.media import Media
from models.comment import Comment
memorial = None
if url:
# TODO - figure out how to condense into just a single db query. Either we have to build the Memorial obj from the tuple returned from exec, or research more on case sensitive searching using SQLAlchemy
# https://bitbucket.org/mitsuhiko/flask/src/tip/examples/minitwit/minitwit.py --> db_query()
memorial = db.session.execute('SELECT id FROM memorials WHERE BINARY memorials.url = :url and memorials.status < 5 LIMIT 1', { 'url': url } ).fetchone()
if memorial:
memorial = Memorial.query.filter_by(id=memorial[0]).first()
memorial.media = Media.get_media(memorial.id, init=init, validate=False)
memorial.comments = Comment.get_comments(memorial.id)
else:
if user_id > 0:
memorial = Memorial.query.filter(Memorial.user_id == user_id, Memorial.status == 1).first()
if memorial:
memorial.media = Media.get_media(memorial.id, init=True, validate=False)
elif create_if_none:
memorial = Memorial(user_id, status=1)
memorial.save_new_memorial()
else:
from lib import sessions
memorial = Memorial(user_id, status=1)
if sessions.save_photo('has'):
memorial.media = Media(media_type=Media.media_types['photo'], filename=sessions.save_photo('get'))
if memorial:
# Need ordered to ensure validation goes through date checking in order
from collections import OrderedDict
memorial.errors = OrderedDict([ ('name', ''), ('dob', ''), ('dod', ''), ('cause', ''), ('epitaph', ''), ('funeral_type', ''), ('funeral_date', ''), ('funeral_loc', ''), ('media', '') ])
memorial.media = ( memorial.media if hasattr(memorial, 'media') and memorial.media else None ) #media = db.relationship('Media', backref = 'memorial', lazy = 'dynamic')
return memorial