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


Python MPost.get_by_uid方法代码示例

本文整理汇总了Python中torlite.model.mpost.MPost.get_by_uid方法的典型用法代码示例。如果您正苦于以下问题:Python MPost.get_by_uid方法的具体用法?Python MPost.get_by_uid怎么用?Python MPost.get_by_uid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在torlite.model.mpost.MPost的用法示例。


在下文中一共展示了MPost.get_by_uid方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: PostHandler

# 需要导入模块: from torlite.model.mpost import MPost [as 别名]
# 或者: from torlite.model.mpost.MPost import get_by_uid [as 别名]

#.........这里部分代码省略.........
                    app2tag_info=self.mpost2catalog.query_by_id(id_rec),
                    dbrec=a,
                    userinfo=self.userinfo,
                    )

    def get_cat_str(self, cats):
        cat_arr = cats.split(',')
        out_str = ''
        for xx in self.cats:
            if str(xx.uid) in cat_arr:
                tmp_str = '''<li><a href="/category/{0}" style="margin:10px auto;"> {1} </a></li>
                '''.format(xx.slug, tornado.escape.xhtml_escape(xx.name))
                out_str += tmp_str

        return (out_str)

    def get_cat_name(self, id_cat):
        for x in self.cats:
            if x['id_cat'] == id_cat:
                return (x['name'])

    def viewit(self, post_id):

        last_post_id = self.get_cookie('last_post_uid')
        self.set_cookie('last_post_uid', post_id)

        if last_post_id:
            self.add_relation(last_post_id, post_id)

        cats = self.mpost2catalog.query_catalog(post_id)
        replys = self.mpost2reply.get_by_id(post_id)
        tag_info = self.mapp2tag.get_by_id(post_id)

        rec = self.mpost.get_by_uid(post_id)

        if not rec:
            kwd = {
                'info': '您要找的云算应用不存在。',
            }
            self.render('html/404.html', kwd=kwd)
            return False

        if cats.count() == 0:
            cat_id = ''
        else:
            cat_id = cats.get().catalog
        kwd = {
            'pager': '',
            'editable': self.editable(),
            'cat_id': cat_id
        }

        self.render('{0}/post/post_view.html'.format(self.tmpl_name),
                    view=rec,
                    unescape=tornado.escape.xhtml_unescape,
                    kwd=kwd,
                    userinfo=self.userinfo,
                    tag_info=tag_info,
                    relations=self.mrel.get_app_relations(rec.uid),
                    replys=replys,

                    )

    def add_relation(self, f_uid, t_uid):
        if False == self.mpost.get_by_uid(t_uid):
            return False
开发者ID:daimon99,项目名称:TorCMS,代码行数:70,代码来源:post_handler.py

示例2: PostHandler

# 需要导入模块: from torlite.model.mpost import MPost [as 别名]
# 或者: from torlite.model.mpost.MPost import get_by_uid [as 别名]

#.........这里部分代码省略.........
    #                 app2tag_info=self.mpost2catalog.query_by_id(id_rec),
    #                 )

    def get_cat_str(self, cats):
        cat_arr = cats.split(",")
        out_str = ""
        for xx in self.cats:
            if str(xx.uid) in cat_arr:
                tmp_str = """<li><a href="/category/{0}" style="margin:10px auto;"> {1} </a></li>
                """.format(
                    xx.slug, tornado.escape.xhtml_escape(xx.name)
                )
                out_str += tmp_str

        return out_str

    def get_cat_name(self, id_cat):
        for x in self.cats:
            if x["id_cat"] == id_cat:
                return x["name"]

    def viewit(self, post_id):

        last_post_id = self.get_cookie("last_post_uid")
        self.set_cookie("last_post_uid", post_id)

        if last_post_id:
            self.add_relation(last_post_id, post_id)

        cats = self.mpost2catalog.query_catalog(post_id)
        replys = self.mpost2reply.get_by_id(post_id)
        tag_info = self.mapp2tag.get_by_id(post_id)

        rec = self.mpost.get_by_uid(post_id)

        if rec == False:
            kwd = {"info": "您要找的云算应用不存在。"}
            self.render("html/404.html", kwd=kwd)
            return False

        if cats.count() == 0:
            cat_id = ""
        else:
            cat_id = cats.get().catalog
        kwd = {"pager": "", "editable": self.editable(), "cat_id": cat_id}

        self.render(
            "tplite/post/viewiki.html",
            view=rec,
            unescape=tornado.escape.xhtml_unescape,
            kwd=kwd,
            userinfo=self.userinfo,
            tag_info=tag_info,
            relations=self.mrel.get_app_relations(rec.uid),
            replys=replys,
        )

    def add_relation(self, f_uid, t_uid):
        print("-" * 40)
        print(f_uid)
        print(t_uid)
        if False == self.mpost.get_by_uid(t_uid):
            return False
        if f_uid == t_uid:
            """
            关联其本身
开发者ID:Ryan007,项目名称:TorCMS,代码行数:70,代码来源:post_handler.py


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