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


Python Comment.get_comments方法代码示例

本文整理汇总了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)
开发者ID:yimun,项目名称:mygroup,代码行数:12,代码来源:app.py

示例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
开发者ID:smaili,项目名称:ripto,代码行数:40,代码来源:memorial.py


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