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


Python MCatalog.query_all方法代码示例

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


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

示例1: PageAjaxHandler

# 需要导入模块: from torcms.model.mcatalog import MCatalog [as 别名]
# 或者: from torcms.model.mcatalog.MCatalog import query_all [as 别名]
class PageAjaxHandler(PageHandler):
    def initialize(self):
        self.init()
        self.mpage = MPage()
        self.mcat = MCatalog()
        self.cats = self.mcat.query_all()
        self.tmpl_router = 'page_ajax'
开发者ID:ivonlee,项目名称:TorCMS,代码行数:9,代码来源:page_handler.py

示例2: IndexHandler

# 需要导入模块: from torcms.model.mcatalog import MCatalog [as 别名]
# 或者: from torcms.model.mcatalog.MCatalog import query_all [as 别名]
class IndexHandler(BaseHandler):
    def initialize(self):
        self.init()
        self.mpost = MPost()
        self.mcat = MCatalog()
        self.mpage = MPage()
        self.mlink = MLink()

    def get_current_user(self):
        return self.get_secure_cookie("user")

    def get(self, input=''):
        if input == '':
            self.index()
        else:
            self.render('html/404.html', kwd={}, userinfo=self.userinfo)

    def index(self):
        cstr = tools.get_uuid()
        self.set_cookie('user_pass', cstr)
        kwd = {
            'cookie_str': cstr
        }
        self.render('index/index.html',
                    userinfo=self.userinfo,
                    catalog_info=self.mcat.query_all(by_order=True),
                    link=self.mlink.query_all(),
                    unescape=tornado.escape.xhtml_unescape,
                    cfg=config.cfg,
                    view=self.mpost.query_most_pic(20),
                    kwd=kwd, )
开发者ID:Sijiu,项目名称:TorCMS,代码行数:33,代码来源:index.py

示例3: category_menu

# 需要导入模块: from torcms.model.mcatalog import MCatalog [as 别名]
# 或者: from torcms.model.mcatalog.MCatalog import query_all [as 别名]
class category_menu(tornado.web.UIModule):
    def render(self):
        self.mcat = MCatalog()
        recs = self.mcat.query_all()
        return self.render_string('doc/modules/showcat_list.html',
                                  recs=recs,
                                  unescape=tornado.escape.xhtml_unescape,
                                  )
开发者ID:ivonlee,项目名称:TorCMS,代码行数:10,代码来源:base_modules.py

示例4: get_footer

# 需要导入模块: from torcms.model.mcatalog import MCatalog [as 别名]
# 或者: from torcms.model.mcatalog.MCatalog import query_all [as 别名]
class get_footer(tornado.web.UIModule):
    def render(self):
        self.mcat = MCatalog()
        all_cats = self.mcat.query_all()
        kwd = {
            'cats': all_cats,
        }
        return self.render_string('tmpl_torlite/modules/menu.html',
                                  kwd=kwd)
开发者ID:Sijiu,项目名称:TorCMS,代码行数:11,代码来源:base_modules.py

示例5: category_menu

# 需要导入模块: from torcms.model.mcatalog import MCatalog [as 别名]
# 或者: from torcms.model.mcatalog.MCatalog import query_all [as 别名]
class category_menu(tornado.web.UIModule):
    def render(self):
        self.mcat = MCatalog()
        recs = self.mcat.query_all()
        out_str = ''
        for rec in recs:
            tmp_str = '''<li><a href="/category/{0}" title="{1}">{1}</a></li>'''.format(rec.slug, rec.name)
            out_str += tmp_str
        return out_str
开发者ID:Sijiu,项目名称:TorCMS,代码行数:11,代码来源:base_modules.py

示例6: ModuleCatMenu

# 需要导入模块: from torcms.model.mcatalog import MCatalog [as 别名]
# 或者: from torcms.model.mcatalog.MCatalog import query_all [as 别名]
class ModuleCatMenu(tornado.web.UIModule):
    def render(self, with_count=True):
        self.mcat = MCatalog()
        all_cats = self.mcat.query_all(by_count=True)
        kwd = {
            'cats': all_cats,
            'with_count': with_count,
        }
        return self.render_string('tmpl_torlite/modules/menu_post.html',
                                  kwd=kwd)
开发者ID:Sijiu,项目名称:TorCMS,代码行数:12,代码来源:base_modules.py

示例7: PostAjaxHandler

# 需要导入模块: from torcms.model.mcatalog import MCatalog [as 别名]
# 或者: from torcms.model.mcatalog.MCatalog import query_all [as 别名]
class PostAjaxHandler(PostHandler):
    def initialize(self):
        self.init()
        self.mpost = MPost()
        self.mcat = MCatalog()
        self.cats = self.mcat.query_all()
        self.mpost_hist = MPostHist()
        self.mpost2catalog = MPost2Catalog()
        self.mpost2reply = MPost2Reply()
        self.mpost2label = MPost2Label()
        self.mrel = MRelation()
        self.tmpl_router = 'post_ajax'
开发者ID:ivonlee,项目名称:TorCMS,代码行数:14,代码来源:post_handler.py

示例8: CategoryHandler

# 需要导入模块: from torcms.model.mcatalog import MCatalog [as 别名]
# 或者: from torcms.model.mcatalog.MCatalog import query_all [as 别名]
class CategoryHandler(BaseHandler):
    def initialize(self):
        self.init()
        self.mpost = MPost()
        self.mcat = MCatalog()
        self.cats = self.mcat.query_all()
        self.mpost2catalog = MPost2Catalog()


    def get(self, url_str=''):
        url_arr = self.parse_url(url_str)

        if len(url_arr) == 1:
            self.list_catalog(url_str)
        elif len(url_arr) == 2:
            self.list_catalog(url_arr[0], url_arr[1])
        else:
            self.render('html/404.html')

    def list_catalog(self, cat_slug, cur_p=''):
        if cur_p == '':
            current_page_num = 1
        else:
            current_page_num = int(cur_p)

        current_page_num = 1 if current_page_num < 1 else current_page_num
        cat_rec = self.mcat.get_by_slug(cat_slug)
        num_of_cat = self.mpost2catalog.count_of_certain_catalog(cat_rec.uid)
        page_num = int(num_of_cat / config.page_num) + 1
        cat_name = cat_rec.name
        kwd = {
            'cat_name': cat_name,
            'cat_slug': cat_slug,
            'unescape': tornado.escape.xhtml_unescape,
            'title': cat_name,
            'current_page': current_page_num
        }

        self.render('doc/catalog/list.html',
                    infos=self.mpost2catalog.query_pager_by_slug(cat_slug, current_page_num),
                    pager=tools.gen_pager_purecss('/category/{0}'.format(cat_slug), page_num, current_page_num),
                    userinfo=self.userinfo,
                    cfg = config.cfg,
                    kwd=kwd)

    def get_random(self):
        return self.mpost.query_random()
开发者ID:ivonlee,项目名称:TorCMS,代码行数:49,代码来源:category_handler.py

示例9: SearchHandler

# 需要导入模块: from torcms.model.mcatalog import MCatalog [as 别名]
# 或者: from torcms.model.mcatalog.MCatalog import query_all [as 别名]
class SearchHandler(BaseHandler):
    def initialize(self):
        self.init()
        self.mpost = MPost()
        self.mcat = MCatalog()
        self.cats = self.mcat.query_all()
        self.mpost2catalog = MPost2Catalog()
        self.ysearch = yunsearch()

    def get(self, url_str=''):
        url_arr = self.parse_url(url_str)

        if url_str == '':
            return
        elif len(url_arr) == 1:
            self.search(url_str)
        elif len(url_arr) == 2:
            self.search(url_arr[0], int(url_arr[1]))
        else:
            kwd = {
                'info': '页面未找到',
            }
            self.render('html/404.html',
                        kwd=kwd,
                        userinfo=  self.userinfo)

    def post(self, url_str=''):
        keyword = self.get_argument('keyword')
        self.search(keyword)

    def search(self, keyword, p_index=1):
        res_all = self.ysearch.get_all_num(keyword)
        results = self.ysearch.search_pager(keyword, page_index=p_index, doc_per_page=20)
        page_num = int(res_all / 20)
        kwd = {'title': '查找结果',
               'pager': '',
               }
        self.render('{0}/search/search.html'.format(self.tmpl_name),
                    kwd=kwd,
                    srecs=results,
                    pager=tools.gen_pager_bootstrap_url('/search/{0}'.format(keyword), page_num, p_index),
                    userinfo = self.userinfo,
                    cfg = config.cfg,
                    )
开发者ID:Sijiu,项目名称:TorCMS,代码行数:46,代码来源:search_handler.py

示例10: MaintainCategoryHandler

# 需要导入模块: from torcms.model.mcatalog import MCatalog [as 别名]
# 或者: from torcms.model.mcatalog.MCatalog import query_all [as 别名]
class MaintainCategoryHandler(BaseHandler):
    def initialize(self):
        self.init()
        self.mclass = MCatalog()
        self.tmpl_router = 'maintain_category'


    def get(self, url_str=''):
        url_arr = self.parse_url(url_str)

        if url_str == 'add':
            self.to_add()
        elif url_str == 'list':
            self.list_catalog()
        elif url_arr[0] == 'modify':
            self.to_modify(url_arr[1])

        elif url_arr[0] == 'delete':

            self.delete_by_uid(url_arr[1])

        else:
            kwd = {
                'info': '页面未找到',
            }
            self.render('html/404.html', kwd=kwd, userinfo = self.userinfo,)

    def post(self, url_str=''):

        url_arr = self.parse_url(url_str)

        if url_arr[0] == 'modify':
            self.update(url_arr[1])
        elif url_str == 'add':
            self.add_catalog()
        elif url_arr[0] == 'add':

            self.p_add_catalog()
        else:
            self.redirect('html/404.html')

    def list_catalog(self):
        kwd = {
            'pager': '',
            'unescape': tornado.escape.xhtml_unescape,
            'title': '最近文档',
        }
        self.render('{0}/{1}/category_list.html'.format(self.tmpl_name, self.tmpl_router),
                    kwd=kwd,
                    view=self.mclass.query_all(by_order=True),
                    format_date=tools.format_date,
                    userinfo=self.userinfo,
                    cfg=config.cfg
                    )

    @tornado.web.authenticated
    def to_add(self):
        kwd = {
            'pager': '',
            'uid': '',
        }
        self.render('{0}/{1}/category_add.html'.format(self.tmpl_name, self.tmpl_router),
                    topmenu='',
                    kwd=kwd,
                    userinfo=self.userinfo,
                    cfg=config.cfg
                    )

    @tornado.web.authenticated
    def update(self, uid):
        raw_data = self.mclass.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()

        if self.tmpl_router == "maintain_category":
            self.mclass.update(uid, post_data)
            self.redirect('/maintain/category/list'.format(uid))
        else:
            if self.mclass.update(uid, post_data):

                output = {
                    'addinfo ': 1,
                }
            else:
                output = {
                    'addinfo ': 0,
                }
            return json.dump(output, self)

    @tornado.web.authenticated
    def to_modify(self, id_rec):
        a = self.mclass.get_by_id(id_rec)
        if self.userinfo.privilege[4] == '1':
            pass
#.........这里部分代码省略.........
开发者ID:Sijiu,项目名称:TorCMS,代码行数:103,代码来源:maintain_handler.py

示例11: PostHandler

# 需要导入模块: from torcms.model.mcatalog import MCatalog [as 别名]
# 或者: from torcms.model.mcatalog.MCatalog import query_all [as 别名]
class PostHandler(BaseHandler):
    def initialize(self):
        self.init()
        self.mpost = MPost()
        self.mcat = MCatalog()
        self.cats = self.mcat.query_all()
        self.mpost_hist = MPostHist()
        self.mpost2catalog = MPost2Catalog()
        self.mpost2reply = MPost2Reply()
        self.mapp2tag = MPost2Label()
        self.mrel = MRelation()
        self.tmpl_router = 'post'

    def get(self, url_str=''):
        url_arr = self.parse_url(url_str)

        if url_str == '':
            self.recent()
        elif len(url_arr) == 1 and url_str.endswith('.html'):
            self.wiki(url_str.split('.')[0])
        elif url_str == 'add_document':
            self.to_add_document()
        elif url_str == 'recent':
            self.recent()
        elif url_str == 'refresh':
            self.refresh()
        elif (url_arr[0] == 'modify'):
            self.to_modify(url_arr[1])
        elif url_arr[0] == 'delete':
            self.delete(url_arr[1])
        elif url_arr[0] == 'ajax_count_plus':
            self.ajax_count_plus(url_arr[1])
        else:
            kwd = {
                'info': '页面未找到',
            }
            self.render('html/404.html', kwd=kwd,
                        userinfo=self.userinfo, )

    def post(self, url_str=''):
        if url_str == '':
            return
        url_arr = url_str.split('/')

        if len(url_arr) == 1 and url_str.endswith('.html'):
            self.add_post()
        if url_arr[0] == 'modify':
            self.update(url_arr[1])
        elif url_str == 'add_document':
            self.user_add_post()
        elif url_arr[0] == 'add_document':
            self.user_add_post()
        else:
            self.redirect('html/404.html')

    def ajax_count_plus(self, uid):
        output = {
            'status': 1 if self.mpost.update_view_count_by_uid(uid) else 0,
        }

        return json.dump(output, self)

    def recent(self, with_catalog=True, with_date=True):
        kwd = {
            'pager': '',
            'unescape': tornado.escape.xhtml_unescape,
            'title': '最近文档',
            'with_catalog': with_catalog,
            'with_date': with_date,
        }
        self.render('{0}/{1}/post_list.html'.format(self.tmpl_name, self.tmpl_router),
                    kwd=kwd,
                    view=self.mpost.query_recent(),
                    view_all=self.mpost.query_all(),
                    format_date=tools.format_date,
                    userinfo=self.userinfo,
                    cfg=config.cfg,
                    )

    def refresh(self):

        kwd = {
            'pager': '',
            'title': '最近文档',
        }
        self.render('{0}/{1}/post_list.html'.format(self.tmpl_name, self.tmpl_router),
                    kwd=kwd,
                    userinfo=self.userinfo,
                    view=self.mpost.query_dated(10),
                    format_date=tools.format_date,
                    unescape=tornado.escape.xhtml_unescape,
                    cfg=config.cfg, )

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

    def wiki(self, uid):
        dbdate = self.mpost.get_by_id(uid)
        if dbdate:
            self.viewit(uid)
#.........这里部分代码省略.........
开发者ID:Sijiu,项目名称:TorCMS,代码行数:103,代码来源:post_handler.py

示例12: PageHandler

# 需要导入模块: from torcms.model.mcatalog import MCatalog [as 别名]
# 或者: from torcms.model.mcatalog.MCatalog import query_all [as 别名]
class PageHandler(BaseHandler):
    def initialize(self):
        self.init()
        self.mpage = MPage()
        self.mcat = MCatalog()
        self.cats = self.mcat.query_all()

    def get(self, url_str=''):
        url_arr = self.parse_url(url_str)
        if url_arr[0] in ['modify', 'edit']:
            self.to_modify(url_arr[1])
        elif url_str == 'list':
            self.list()
        elif url_arr[0] == 'ajax_count_plus':
            self.ajax_count_plus(url_arr[1])
        elif len(url_arr) == 1 and url_str.endswith('.html'):
            self.to_view(url_str.split('.')[0])
        else:
            self.render('html/404.html', userinfo=self.userinfo, kwd={})

    def post(self, url_str=''):
        url_arr = self.parse_url(url_str)

        if url_arr[0] in ['modify', 'edit']:
            self.update(url_arr[1])
        else:
            self.add_page()

    def to_view(self, slug):
        rec_page = self.mpage.get_by_slug(slug)
        if rec_page:
            self.viewit(rec_page)
        else:
            self.to_add(slug)

    @tornado.web.authenticated
    def to_add(self, citiao):
        if self.check_doc_priv(self.userinfo)['ADD']:
            pass
        else:
            return False
        kwd = {
            'cats': self.cats,
            'slug': citiao,
            'pager': '',
        }
        self.render('doc/page/page_add.html',
                    kwd=kwd,
                    userinfo=self.userinfo, )

    def __could_edit(self, slug):
        page_rec = self.mpage.get_by_slug(slug)
        if not page_rec:

            return False
        if self.check_doc_priv(self.userinfo)['EDIT'] or page_rec.id_user == self.userinfo.user_name:
            return True
        else:
            return False

    @tornado.web.authenticated
    def update(self, slug):
        if self.__could_edit(slug):
            pass
        else:
            return False
        post_data = {}
        for key in self.request.arguments:
            post_data[key] = self.get_arguments(key)

        if 'slug' in post_data:
            pass
        else:
            self.set_status(400)
            return False

        self.mpage.update(slug, post_data)
        self.redirect('/page/{0}.html'.format(post_data['slug'][0]))

    @tornado.web.authenticated
    def to_modify(self, slug):
        if self.__could_edit(slug):
            pass
        else:
            return False

        kwd = {
            'pager': '',

        }
        self.render('doc/page/page_edit.html',
                    view=self.mpage.get_by_slug(slug),
                    kwd=kwd,
                    unescape=tornado.escape.xhtml_unescape,
                    cfg=config.cfg,
                    userinfo=self.userinfo,
                    )

    def viewit(self, rec):
        kwd = {
#.........这里部分代码省略.........
开发者ID:ivonlee,项目名称:TorCMS,代码行数:103,代码来源:page_handler.py

示例13: PageHandler

# 需要导入模块: from torcms.model.mcatalog import MCatalog [as 别名]
# 或者: from torcms.model.mcatalog.MCatalog import query_all [as 别名]
class PageHandler(BaseHandler):
    def initialize(self):
        self.init()
        self.mpage = MPage()
        self.mcat = MCatalog()
        self.cats = self.mcat.query_all()

    def get(self, url_str=''):
        url_arr = self.parse_url(url_str)
        if url_arr[0] == 'modify':
            self.to_modify(url_arr[1])
        elif url_str == 'list':
           self.list()
        elif url_arr[0] == 'ajax_count_plus':
            self.ajax_count_plus(url_arr[1])
        elif len(url_arr) == 1 and url_str.endswith('.html'):
            self.wiki(url_str.split('.')[0])
        else:
            self.render('html/404.html', userinfo = self.userinfo, kwd = {})

    def post(self, url_str=''):
        url_arr = self.parse_url(url_str)

        if url_arr[0] == 'modify':
            self.update(url_arr[1])
        else:
            self.wikinsert()

    def wiki(self, slug):
        dbdate = self.mpage.get_by_slug(slug)
        if dbdate:
            self.viewit(dbdate)
        else:
            self.to_add(slug)

    @tornado.web.authenticated
    def to_add(self, citiao):
        kwd = {
            'cats': self.cats,
            'slug': citiao,
            'pager': '',
        }
        self.render('{0}/page/page_add.html'.format(self.tmpl_name), kwd=kwd)

    @tornado.web.authenticated
    def update(self, slug):

        post_data = {}
        for key in self.request.arguments:
            post_data[key] = self.get_arguments(key)

        if 'slug' in post_data:
            pass
        else:
            self.set_status(400)
            return False

        self.mpage.update(slug, post_data)
        self.redirect('/page/{0}.html'.format(post_data['slug'][0]))

    @tornado.web.authenticated
    def to_modify(self, slug):
        kwd = {
            'pager': '',

        }
        self.render('{0}/page/page_edit.html'.format(self.tmpl_name),
                    view=self.mpage.get_by_slug(slug),
                    kwd=kwd,
                    unescape=tornado.escape.xhtml_unescape,
                    cfg  = config.cfg,
                    userinfo = self.userinfo,
                    )

    def viewit(self, dbdata):
        kwd = {
            'pager': '',
            'editable': 1 if self.get_current_user() else 0,
        }
        self.render('{0}/page/page_view.html'.format(self.tmpl_name),
                    view=dbdata,
                    unescape=tornado.escape.xhtml_unescape,
                    kwd=kwd,
                    format_date=tools.format_date,
                    userinfo=self.userinfo,
                    cfg = config.cfg
                    )

    def ajax_count_plus(self, slug):
        output = {
            'status': 1 if self.mpage.view_count_plus(slug) else 0,
        }

        return json.dump(output, self)

    def list(self):
        kwd = {
                    'pager': '',
                    'unescape': tornado.escape.xhtml_unescape,
                    'title': '单页列表',
#.........这里部分代码省略.........
开发者ID:Sijiu,项目名称:TorCMS,代码行数:103,代码来源:page_handler.py


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