• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python mspec.SpesubModel类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中torlite.model.mspec.SpesubModel的典型用法代码示例。如果您正苦于以下问题:Python SpesubModel类的具体用法?Python SpesubModel怎么用?Python SpesubModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: initialize

    def initialize(self):

        self.mdb = MPage()
        self.mcat = MCatalog()
        self.cats = self.mcat.query_all()
        self.mspec = SpesubModel()
        self.specs = self.mspec.get_all()
开发者ID:ifcheung2012,项目名称:TorCMS,代码行数:7,代码来源:page_handler.py


示例2: render

 def render(self):
     self.mcat = SpesubModel()
     all_cats = self.mcat.get_all()
     kwd = {
         'cats': all_cats,
     }
     return self.render_string('{0}/modules/spec_menu.html'.format(config.torlite_template_name), kwd=kwd)
开发者ID:simudream,项目名称:TorCMS,代码行数:7,代码来源:modef.py


示例3: render

 def render(self):
     self.mcat = SpesubModel()
     all_cats = self.mcat.get_all()
     kwd = {
         'cats': all_cats,
     }
     return self.render_string('tplite/modules/spec_menu.html', kwd=kwd)
开发者ID:Geoion,项目名称:TorCMS,代码行数:7,代码来源:menu.py


示例4: ModuleSpecMenu

class ModuleSpecMenu(tornado.web.UIModule):
    def render(self):
        self.mcat = SpesubModel()
        all_cats = self.mcat.get_all()
        kwd = {
            'cats': all_cats,
        }
        return self.render_string('tplite/modules/spec_menu.html', kwd=kwd)
开发者ID:Geoion,项目名称:TorCMS,代码行数:8,代码来源:menu.py


示例5: initialize

    def initialize(self):

        self.mpost = MPost()
        self.mcat = MCatalog()
        self.cats = self.mcat.query_all()
        self.mspec = SpesubModel()
        self.specs = self.mspec.get_all()
        self.mpost2catalog = MPost2Catalog()
开发者ID:Geoion,项目名称:TorCMS,代码行数:8,代码来源:cat_handler.py


示例6: initialize

 def initialize(self):
     self.muser = MUser()
     self.mpage = MPage()
     self.mdb = MPost()
     self.mcat = MCatalog()
     self.cats = self.mcat.query_all()
     self.mspec = SpesubModel()
     if self.get_current_user():
         self.userinfo = self.muser.get_by_id(self.get_current_user())
     else:
         self.userinfo = None
开发者ID:Ryan007,项目名称:TorCMS,代码行数:11,代码来源:spec_handler.py


示例7: initialize

 def initialize(self):
     self.muser = MUser()
     self.mwiki = MWiki()
     self.mcat = MCatalog()
     self.cats = self.mcat.query_all()
     self.mspec = SpesubModel()
     self.specs = self.mspec.get_all()
     self.mwiki_hist = MWikiHist()
     if self.get_current_user():
         self.userinfo = self.muser.get_by_id(self.get_current_user())
     else:
         self.userinfo = None
开发者ID:Ryan007,项目名称:TorCMS,代码行数:12,代码来源:wiki_handler.py


示例8: CategoryHandler

class CategoryHandler(BaseHandler):
    def initialize(self):
        self.init()
        self.muser = MUser()
        self.mpost = MPost()
        self.mcat = MCatalog()
        self.cats = self.mcat.query_all()
        self.mspec = SpesubModel()
        self.specs = self.mspec.get_all()
        self.mpost2catalog = MPost2Catalog()
        if self.get_current_user():
            self.userinfo = self.muser.get_by_id(self.get_current_user())
        else:
            self.userinfo = None

    def get(self, input=''):
        if len(input) > 0:
            ip_arr = input.split(r'/')
        if input == '':
            pass
        elif len(ip_arr) == 1:
            self.list_catalog(input)
        elif len(ip_arr) == 2:
            self.list_catalog(ip_arr[0], ip_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)

        cat_rec = self.mcat.get_by_slug(cat_slug)
        num_of_cat = self.mpost2catalog.catalog_record_number(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,
        }

        self.render('{0}/catalog/list.html'.format(self.tmpl_name),
                    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,
                    kwd=kwd)

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


示例9: SearchHandler

class SearchHandler(BaseHandler):
    def initialize(self):
        # analyzer = ChineseAnalyzer()
        # schema = Schema(title=TEXT(stored=True, analyzer = analyzer), path=ID(stored=True), content=TEXT(stored=True, analyzer=analyzer))
        # ix = config.ix
        # self.searcher = config.searcher
        # self.parser = config.parser
        # self.parser = QueryParser("content", schema=ix.schema)

        self.muser = MUser()
        self.mpost = MPost()
        self.mcat = MCatalog()
        self.cats = self.mcat.query_all()
        self.mspec = SpesubModel()
        self.specs = self.mspec.get_all()
        self.mpost_hist = MPostHist()
        self.mpost2catalog = MPost2Catalog()
        if self.get_current_user():
            self.userinfo = self.muser.get_by_id(self.get_current_user())
        else:
            self.userinfo = None

    def get(self, url_str=''):

        if url_str == '':
            return
        elif len(url_str) > 0:
            self.search(url_str)
        else:
            kwd = {
                'info': '页面未找到',
            }
            self.render('html/404.html', kwd=kwd)

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

    def to_find(self, ):
        kwd = {
            'pager': '',
        }
        self.render('tplite/post/find.html', topmenu='', kwd=kwd)
    def search(self, keyword):
        results = whoosh_search(keyword, 20)
        # reswhoosh_search.keyworde limit=3limit=30)
        kwd = {'title':'查找结果'}
        self.render('tplite/search/search.html',
                    kwd=kwd,
                    srecs = results,
                    )
开发者ID:Geoion,项目名称:TorCMS,代码行数:51,代码来源:search_handler.py


示例10: SearchHandler

class SearchHandler(BaseHandler):
    def initialize(self):
        self.init()
        self.muser = MUser()
        self.mpost = MPost()
        self.mcat = MCatalog()
        self.cats = self.mcat.query_all()
        self.mspec = SpesubModel()
        self.specs = self.mspec.get_all()
        self.mpost_hist = MPostHist()
        self.mpost2catalog = MPost2Catalog()
        self.ysearch = yunsearch()
        if self.get_current_user():
            self.userinfo = self.muser.get_by_id(self.get_current_user())
        else:
            self.userinfo = None

    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)

    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),
                    cfg = config.cfg
                    )
开发者ID:xiaolushare,项目名称:TorCMS,代码行数:49,代码来源:search_handler.py


示例11: initialize

    def initialize(self):
        self.muser = MUser()
        self.mpost = MPost()
        self.mcat = MCatalog()
        self.cats = self.mcat.query_all()
        self.mspec = SpesubModel()
        self.specs = self.mspec.get_all()
        self.mpost_hist = MPostHist()
        self.mpost2catalog = MPost2Catalog()
        self.mreply = MReply()

        if self.get_current_user():
            self.userinfo = self.muser.get_by_id(self.get_current_user())
        else:
            self.userinfo = None
开发者ID:Geoion,项目名称:TorCMS,代码行数:15,代码来源:post_handler.py


示例12: initialize

    def initialize(self):
        self.init()
        self.muser = MUser()
        self.mpost = MPost()
        self.mcat = MCatalog()
        self.cats = self.mcat.query_all()
        self.mspec = SpesubModel()
        self.specs = self.mspec.get_all()
        self.mpost_hist = MPostHist()
        self.mpost2catalog = MPost2Catalog()
        self.mpost2reply = MPost2Reply()
        self.mapp2tag = MPost2Label()
        self.mrel = MRelation()
        self.tmpl_router = 'post_ajax'

        if self.get_current_user():
            self.userinfo = self.muser.get_by_id(self.get_current_user())
        else:
            self.userinfo = None
开发者ID:southwestjiaotongunivercity,项目名称:TorCMS,代码行数:19,代码来源:post_handler.py


示例13: initialize

    def initialize(self):
        analyzer = ChineseAnalyzer()
        schema = Schema(title=TEXT(stored=True, analyzer = analyzer), path=ID(stored=True), content=TEXT(stored=True, analyzer=analyzer))
        ix = open_dir("lib/whoosh") # for read only
        self.searcher = ix.searcher()
        self.parser = QueryParser("content", schema=ix.schema)

        self.muser = MUser()
        self.mpost = MPost()
        self.mcat = MCatalog()
        self.cats = self.mcat.query_all()
        self.mspec = SpesubModel()
        self.specs = self.mspec.get_all()
        self.mpost_hist = MPostHist()
        self.mpost2catalog = MPost2Catalog()
        if self.get_current_user():
            self.userinfo = self.muser.get_by_id(self.get_current_user())
        else:
            self.userinfo = None
开发者ID:jiajie999,项目名称:TorCMS,代码行数:19,代码来源:search_handler.py


示例14: initialize

    def initialize(self):
        # analyzer = ChineseAnalyzer()
        # schema = Schema(title=TEXT(stored=True, analyzer = analyzer), path=ID(stored=True), content=TEXT(stored=True, analyzer=analyzer))
        # ix = config.ix
        # self.searcher = config.searcher
        # self.parser = config.parser
        # self.parser = QueryParser("content", schema=ix.schema)

        self.muser = MUser()
        self.mpost = MPost()
        self.mcat = MCatalog()
        self.cats = self.mcat.query_all()
        self.mspec = SpesubModel()
        self.specs = self.mspec.get_all()
        self.mpost_hist = MPostHist()
        self.mpost2catalog = MPost2Catalog()
        self.ysearch = yunsearch()
        if self.get_current_user():
            self.userinfo = self.muser.get_by_id(self.get_current_user())
        else:
            self.userinfo = None
开发者ID:Ryan007,项目名称:TorCMS,代码行数:21,代码来源:search_handler.py


示例15: PostHandler

class PostHandler(BaseHandler):
    def initialize(self):
        self.init()
        self.muser = MUser()
        self.mpost = MPost()
        self.mcat = MCatalog()
        self.cats = self.mcat.query_all()
        self.mspec = SpesubModel()
        self.specs = self.mspec.get_all()
        self.mpost_hist = MPostHist()
        self.mpost2catalog = MPost2Catalog()
        self.mpost2reply = MPost2Reply()
        self.mapp2tag = MPost2Label()
        self.mrel = MRelation()
        self.tmpl_router = 'post'

        if self.get_current_user():
            self.userinfo = self.muser.get_by_id(self.get_current_user())
        else:
            self.userinfo = None

    def get(self, url_str=''):

        if url_str == '':
            self.recent()
        url_arr = url_str.split('/')

        if 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])

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

    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 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,
                    )

    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, )

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

    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)
#.........这里部分代码省略.........
开发者ID:southwestjiaotongunivercity,项目名称:TorCMS,代码行数:101,代码来源:post_handler.py


示例16: WikiHandler

class WikiHandler(BaseHandler):
    def initialize(self):
        self.init()
        self.muser = MUser()
        self.mwiki = MWiki()
        self.mcat = MCatalog()
        self.cats = self.mcat.query_all()
        self.mspec = SpesubModel()
        self.specs = self.mspec.get_all()
        self.mwiki_hist = MWikiHist()
        if self.get_current_user():
            self.userinfo = self.muser.get_by_id(self.get_current_user())
        else:
            self.userinfo = None

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

        if url_str == 'recent':
            self.recent()
        elif url_str == 'refresh':
            self.refresh()
        elif (url_arr[0] == 'edit'):
            self.to_modify(url_arr[1])
        elif len(url_arr) == 1:
            self.wiki(url_str)
        else:
            kwd = {
                'info': '页面未找到',
            }
            self.render('html/404.html', kwd=kwd)

    def post(self, input=''):
        if input == '':
            return
        url_arr = input.split(r'/')
        if url_arr[0] == 'edit':
            self.update(url_arr[1])
        elif url_arr[0] == 'add':
            self.wikinsert()
        else:
            self.redirect('html/404.html')

    def recent(self):
        kwd = {
            'pager': '',
            'unescape': tornado.escape.xhtml_unescape,
            'title': '最近文档',
        }
        self.render('{0}/wiki/wiki_list.html'.format(self.tmpl_name),
                    kwd=kwd,
                    view=self.mwiki.query_recent(),
                    format_date=tools.format_date, )

    def refresh(self):
        kwd = {
            'pager': '',
            'unescape': tornado.escape.xhtml_unescape,
            'title': '最近文档',
        }
        self.render('{0}/wiki/wiki_list.html'.format(self.tmpl_name),
                    kwd=kwd,
                    view=self.mwiki.query_dated(16),
                    format_date=tools.format_date, )

    def wiki(self, title):
        dbdate = self.mwiki.get_by_wiki(title)
        if dbdate:
            self.mwiki.update_view_count_by_uid(dbdate.uid)
            self.viewit(dbdate)
        else:
            self.to_add(title)

    @tornado.web.authenticated
    def to_add(self, title):
        kwd = {
            'cats': self.cats,
            'specs': self.specs,
            'title': title,
            'pager': '',
        }
        self.render('{0}/wiki/wiki_add.html'.format(self.tmpl_name), kwd=kwd, )

    @tornado.web.authenticated
    def update(self, uid):
        raw_data = self.mwiki.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()
        self.mwiki.update(uid, post_data)
        self.mwiki_hist.insert_data(raw_data)
        self.redirect('/wiki/{0}'.format(tornado.escape.url_escape(post_data['title'][0])))

#.........这里部分代码省略.........
开发者ID:net4nt,项目名称:TorCMS,代码行数:101,代码来源:wiki_handler.py


示例17: SearchHandler

class SearchHandler(BaseHandler):
    def initialize(self):
        # analyzer = ChineseAnalyzer()
        # schema = Schema(title=TEXT(stored=True, analyzer = analyzer), path=ID(stored=True), content=TEXT(stored=True, analyzer=analyzer))
        # ix = config.ix
        # self.searcher = config.searcher
        # self.parser = config.parser
        # self.parser = QueryParser("content", schema=ix.schema)

        self.muser = MUser()
        self.mpost = MPost()
        self.mcat = MCatalog()
        self.cats = self.mcat.query_all()
        self.mspec = SpesubModel()
        self.specs = self.mspec.get_all()
        self.mpost_hist = MPostHist()
        self.mpost2catalog = MPost2Catalog()
        self.ysearch = yunsearch()
        if self.get_current_user():
            self.userinfo = self.muser.get_by_id(self.get_current_user())
        else:
            self.userinfo = None

    def get(self, url_str=''):
        if len(url_str) > 0:
            url_arr = url_str.split('/')
        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)



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

    def to_find(self, ):
        kwd = {
            'pager': '',
        }
        self.render('tplite/post/find.html', topmenu='', kwd=kwd)

    def search(self, keyword, p_index = 1):

        res_all = self.ysearch.get_all_num(keyword)

        # res_all = get_all_num(keyword)
        # results = self.ysearch.search(keyword, 20)
        results = self.ysearch.search_pager(keyword, page_index=p_index, doc_per_page=20)
        print('-' * 40)
        page_num = int(res_all / 20)
        kwd = {'title':'查找结果',
               'pager': '',
               }
        self.render('tplite/search/search.html',
                    kwd=kwd,
                    srecs = results,
                    pager = tools.gen_pager_bootstrap_url('/search/{0}'.format(keyword), page_num, p_index),
                    )
开发者ID:Ryan007,项目名称:TorCMS,代码行数:67,代码来源:search_handler.py


示例18: SpecHandler

class SpecHandler(BaseHandler):
    def initialize(self):
        self.muser = MUser()
        self.mpage = MPage()
        self.mdb = MPost()
        self.mcat = MCatalog()
        self.cats = self.mcat.query_all()
        self.mspec = SpesubModel()
        if self.get_current_user():
            self.userinfo = self.muser.get_by_id(self.get_current_user())
        else:
            self.userinfo = None


    def get(self, input=''):
        if len(input) > 0:
            ip_arr = input.split(r'/')
        if input == '':
            self.index()
        elif input == 'add':
            self.to_add()
        elif len(ip_arr) == 1:
            self.list(input)
        elif len(ip_arr) == 2 and ip_arr[1] == 'edit':
            self.to_edit(ip_arr[0])
        else:
            self.render('/html/404.html')

    def post(self, input=''):
        if len(input) > 0:
            ip_arr = input.split(r'/')
        if input == '':
            pass
        elif input == 'add':
            self.add()
        elif len(ip_arr) == 2 and ip_arr[1] == 'edit':
            self.edit(ip_arr[0])
        else:
            self.render('/html/404.html')
        self.redirect('/spec/')

    @tornado.web.authenticated
    def edit(self, uid):
        post_data = {}
        for key in self.request.arguments:
            post_data[key] = self.get_arguments(key)
        self.mspec.update(uid, post_data)

    @tornado.web.authenticated
    def add(self):
        post_data = {}
        for key in self.request.arguments:
            post_data[key] = self.get_arguments(key)

        self.mspec.addata(post_data)

    @tornado.web.authenticated
    def to_edit(self, uid):
        spec_rec = self.mspec.get_by_id(uid)
        self.render('tplite/spec/edit.html', spec_rec=spec_rec)

    @tornado.web.authenticated
    def to_add(self):

        print('to_add')
        self.render('tplite/spec/add.html')

    def list(self, spec_slug):
        '''
        列出专题信息,按某一分类
        '''
        page_rec = self.mspec.get_by_slug(spec_slug)
        kwd = {
            'editable': self.editable()
        }
        self.render('tplite/spec/list.html',
                    kwd=kwd,
                    spec=page_rec,
                    unescape=tornado.escape.xhtml_unescape,
                    spec_recs=self.mdb.query_by_spec(page_rec.uid),
        )


    def index(self):
        kwd = {
            'editable': self.editable()
        }
        spec_recs = self.mspec.get_all()
        self.render('tplite/spec/index.html', spec_recs=spec_recs, kwd=kwd)
开发者ID:Ryan007,项目名称:TorCMS,代码行数:89,代码来源:spec_handler.py


示例19: SpecHandler

class SpecHandler(BaseHandler):
    def initialize(self):
        self.mpage = MPage()
        self.mdb = MPost()
        self.mcat = MCatalog()
        self.cats = self.mcat.query_all()
        self.mspec = SpesubModel()


    def get(self, input=''):
        if len(input) > 0:
            ip_arr = input.split(r'/')
        if input == '':
            self.index()
        elif input == 'add':
            self.to_add()
        elif len(ip_arr) == 1:
            self.list(input)
        elif len(ip_arr) == 2 and ip_arr[1] == 'edit':
            self.to_edit(ip_arr[0])
        else:
            self.render('/html/404.html')

    def post(self, input=''):
        if len(input) > 0:
            ip_arr = input.split(r'/')
        if input == '':
            pass
        elif input == 'add':
            self.add()
        elif len(ip_arr) == 2 and ip_arr[1] == 'edit':
            self.edit(ip_arr[0])
        else:
            self.render('/html/404.html')
        self.redirect('/spec/')

    @tornado.web.authenticated
    def edit(self, uid):
        post_data = {}
        for key in self.request.arguments:
            post_data[key] = self.get_arguments(key)
        self.mspec.update(uid, post_data)

    @tornado.web.authenticated
    def add(self):
        post_data = {}
        for key in self.request.arguments:
            post_data[key] = self.get_arguments(key)

        self.mspec.addata(post_data)

    @tornado.web.authenticated
    def to_edit(self, uid):
        spec_rec = self.mspec.get_by_id(uid)
        self.render('tplite/spec/edit.html', spec_rec=spec_rec)

    @tornado.web.authenticated
    def to_add(self):
        # spec_rec = self.mspec.get_by_id(uid)
        uuu = self.mcat.query_all()
        self.render('tplite/spec/add.html', cat_recs=uuu)

    def list(self, spec_slug):
        '''
        列出专题信息,按某一分类
        '''
        page_rec = self.mspec.get_by_slug(spec_slug)
        # content = self.mpage.get_by_wiki(page_rec.name)

        # if content is None:
        # re_url = '/page/{0}'.format(tornado.escape.url_escape(page_rec.name))
        #     self.redirect(re_url)


        recs = self.mdb.query_by_spec(page_rec.id)
        kwd = {
            # 'spec': content,
            # 'view': recs,

            'editable': self.editable()
        }
        self.render('tplite/spec/list.html',
                    kwd=kwd,
                    spec=page_rec,
                    unescape=tornado.escape.xhtml_unescape,
                    spec_recs=recs)


    def index(self):
        kwd = {
            # 'spec': content,
            # 'view': recs,
            'editable': self.editable()
        }
        spec_recs = self.mspec.get_all()
        self.render('tplite/spec/index.html', spec_recs=spec_recs, kwd=kwd)
开发者ID:ifcheung2012,项目名称:TorCMS,代码行数:96,代码来源:spec_handler.py


示例20: CatHandler

class CatHandler(BaseHandler):
    def initialize(self):

        self.mpost = MPost()
        self.mcat = MCatalog()
        self.cats = self.mcat.query_all()
        self.mspec = SpesubModel()
        self.specs = self.mspec.get_all()
        self.mpost2catalog = MPost2Catalog()

    def get(self, input=''):
        if len(input) > 0:
            ip_arr = input.split(r'/')
        if input == '':
            pass
        elif len(ip_arr) == 1 :
            self.list_catalog(input)
        elif len(ip_arr) == 2:
            self.list_catalog(ip_arr[0], ip_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)

        cat_rec = self.mcat.get_by_slug(cat_slug)
        num_of_cat = self.mpost2catalog.catalog_record_number(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,
        }

        self.render('tplite/catalog/list.html',
                    infos=self.mpost2catalog.query_pager_by_slug(cat_slug,current_page_num),
                    pager = tools.gen_pager(cat_slug, page_num, current_page_num),
                    kwd=kwd)

    # def view_cat_old(self, cat_slug, cur_p=''):
    #     if cur_p == '':
    #         current = 1
    #     else:
    #         current = int(cur_p)
    #
    #     cat_rec = self.mcat.get_by_slug(cat_slug)
    #     num_of_cat = self.mpost.get_num_by_cat(cat_rec.id_cat)
    #     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,
    #         'pager': tools.gen_pager(cat_slug, page_num, current),
    #         'title': cat_name,
    #     }
    #     for x in self.cats:
    #         if x.slug == cat_slug:
    #             search_str = ',{0},'.format(x.id_cat)
    #     dbdata = self.mpost.query_cat_by_pager(search_str, current)
    #     self.render('tplite/post/all.html',
    #                 kwd = kwd,
    #                 view=dbdata,
    #                 rand_recs = self.get_random(),
    #                 format_date = tools.format_date)



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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python muser.MUser类代码示例发布时间:2022-05-27
下一篇:
Python mpost.MPost类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap