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


Python MPost.query_by_cat方法代码示例

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


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

示例1: list_categories

# 需要导入模块: from torlite.model.mpost import MPost [as 别名]
# 或者: from torlite.model.mpost.MPost import query_by_cat [as 别名]
class list_categories(tornado.web.UIModule):
    def render(self, cat_id, list_num):
        self.mpost = MPost()
        recs = self.mpost.query_by_cat(cat_id, list_num)
        out_str = ''
        for rec in recs:
            tmp_str = '''<li><a href="/{0}">{1}</a></li>'''.format(rec.title, rec.title)
            out_str += tmp_str
        return out_str
开发者ID:vaveee,项目名称:TorCMS,代码行数:11,代码来源:modef.py

示例2: PostHandler

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

#.........这里部分代码省略.........
            kwd=kwd,
            view=self.mpost.query_recent(),
            format_date=tools.format_date,
            userinfo=self.userinfo,
        )

    def refresh(self):

        kwd = {"pager": "", "title": "最近文档"}
        self.render(
            "tplite/post/refresh.html",
            kwd=kwd,
            userinfo=self.userinfo,
            view=self.mpost.query_dated(10),
            format_date=tools.format_date,
            unescape=tornado.escape.xhtml_unescape,
        )

    def post_find(self):
        keyword = self.get_argument("keyword")
        self.find(keyword)

    def find(self, keyword):
        kwd = {"pager": "", "unescape": tornado.escape.xhtml_unescape, "title": "查找结果"}
        self.render("tplite/post/find_list.html".format(input), kwd=kwd, view=self.mpost.get_by_keyword(keyword))

    def get_random(self):
        return self.mpost.query_random()

    def view_cat(self, cat_slug):
        for x in self.cats:
            if x.slug == cat_slug:
                search_str = ",{0},".format(x.id_cat)
        dbdata = self.mpost.query_by_cat(search_str)
        self.render("tplite/post/all.html", view=dbdata, unescape=tornado.escape.xhtml_unescape)

    def wiki(self, uid):
        dbdate = self.mpost.get_by_id(uid)
        if dbdate:
            self.mpost.update_view_count_by_uid(dbdate.uid)
            self.viewit(uid)
        else:

            self.to_add(uid)

    def to_add_document(self,):
        kwd = {"pager": "", "cats": self.cats, "specs": self.specs, "uid": ""}
        self.render(
            "tplite/post/addwiki.html", topmenu="", kwd=kwd, tag_infos=self.mcat.query_all(), userinfo=self.userinfo
        )

    @tornado.web.authenticated
    def to_add(self, uid):
        kwd = {"cats": self.cats, "specs": self.specs, "uid": uid, "pager": ""}
        self.render("tplite/post/addwiki.html", kwd=kwd, tag_infos=self.mcat.query_all())

    @tornado.web.authenticated
    def update(self, uid):
        raw_data = self.mpost.get_by_id(uid)
        if self.userinfo.privilege[2] == "1" or raw_data.user_name == self.get_current_user():
            pass
        else:
            return False
        post_data = {}
        for key in self.request.arguments:
            post_data[key] = self.get_arguments(key)
开发者ID:Ryan007,项目名称:TorCMS,代码行数:70,代码来源:post_handler.py

示例3: PostHandler

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

#.........这里部分代码省略.........
            'pager': '',

            'title': '最近文档',
        }
        self.render('tplite/post/all.html'.format(input),
                    kwd=kwd,
                    view=self.mpost.query_dated(60),
                    format_date=tools.format_date,
                    unescape=tornado.escape.xhtml_unescape, )

    def post_find(self):
        keyword = self.get_argument('keyword')
        self.find(keyword)

    def find(self, keyword):
        kwd = {
            'pager': '',
            'unescape': tornado.escape.xhtml_unescape,
            'title': '查找结果',
        }
        self.render('tplite/post/find_list.html'.format(input),
                    kwd=kwd,
                    view=self.mpost.get_by_keyword(keyword),
        )


    def get_random(self):
        return self.mpost.query_random()

    def view_cat(self, cat_slug):
        for x in self.cats:
            if x.slug == cat_slug:
                search_str = ',{0},'.format(x.id_cat)
        dbdata = self.mpost.query_by_cat(search_str)
        self.render('tplite/post/all.html', view=dbdata, unescape=tornado.escape.xhtml_unescape)

    def wiki(self, uid):
        dbdate = self.mpost.get_by_id(uid)
        if dbdate:
            self.mpost.update_view_count_by_uid(dbdate.uid)
            self.viewit(dbdate)
        else:
            self.to_add(uid)

    @tornado.web.authenticated
    def to_add(self, uid):
        kwd = {
            'cats': self.cats,
            'specs': self.specs,
            'uid': uid,
            'pager': '',
        }
        self.render('tplite/post/addwiki.html', kwd=kwd, tag_infos=self.mcat.query_all(), )

    @tornado.web.authenticated
    def update(self, uid):
        raw_data = self.mpost.get_by_id(uid)
        if self.userinfo.privilege[2] == '1' or raw_data.user_name == self.get_current_user():
            pass
        else:
            return False
        post_data = {}
        for key in self.request.arguments:
            post_data[key] = self.get_arguments(key)
        post_data['user_name'] = self.get_current_user()
开发者ID:Geoion,项目名称:TorCMS,代码行数:69,代码来源:post_handler.py

示例4: PostHandler

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

#.........这里部分代码省略.........
            'pager': '',
            'title': '最近文档',
        }
        self.render('tplite/post/refresh.html',
                    kwd=kwd,
                    userinfo=self.userinfo,
                    view=self.mpost.query_dated(10),
                    format_date=tools.format_date,
                    unescape=tornado.escape.xhtml_unescape, )

    def post_find(self):
        keyword = self.get_argument('keyword')
        self.find(keyword)

    def find(self, keyword):
        kwd = {
            'pager': '',
            'unescape': tornado.escape.xhtml_unescape,
            'title': '查找结果',
        }
        self.render('tplite/post/find_list.html'.format(input),
                    kwd=kwd,
                    view=self.mpost.get_by_keyword(keyword),
        )


    def get_random(self):
        return self.mpost.query_random()

    def view_cat(self, cat_slug):
        for x in self.cats:
            if x.slug == cat_slug:
                search_str = ',{0},'.format(x.id_cat)
        dbdata = self.mpost.query_by_cat(search_str)
        self.render('tplite/post/all.html', view=dbdata, unescape=tornado.escape.xhtml_unescape)

    def wiki(self, uid):
        dbdate = self.mpost.get_by_id(uid)
        if dbdate:
            self.mpost.update_view_count_by_uid(dbdate.uid)
            self.viewit(uid)
        else:

            self.to_add(uid)

    def to_add_document(self, ):
        kwd = {
            'pager': '',
            'cats': self.cats,
            'specs': self.specs,
            'uid': '',

        }
        self.render('tplite/post/addwiki.html', topmenu='',
                    kwd=kwd,
                    tag_infos=self.mcat.query_all(),
                    userinfo = self.userinfo,
        )


    @tornado.web.authenticated
    def to_add(self, uid):
        kwd = {
            'cats': self.cats,
            'specs': self.specs,
            'uid': uid,
开发者ID:smzhao,项目名称:TorCMS,代码行数:70,代码来源:post_handler.py


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