本文整理汇总了Python中torcms.model.mcatalog.MCatalog类的典型用法代码示例。如果您正苦于以下问题:Python MCatalog类的具体用法?Python MCatalog怎么用?Python MCatalog使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MCatalog类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: render
def render(self, *args, **kwargs):
self.mpost2catalog = MPost2Catalog()
self.mcat = MCatalog()
cat_slug = args[0]
current = int(args[1])
# cat_slug 分类
# current 当前页面
cat_rec = self.mcat.get_by_slug(cat_slug)
num_of_cat = self.mpost2catalog.catalog_record_number(cat_rec.uid)
tmp_page_num = int(num_of_cat / config.page_num)
page_num = tmp_page_num if abs(tmp_page_num - num_of_cat / config.page_num) < 0.1 else tmp_page_num + 1
kwd = {
'page_home': False if current <= 1 else True,
'page_end': False if current >= page_num else True,
'page_pre': False if current <= 1 else True,
'page_next': False if current >= page_num else True,
}
return self.render_string('tmpl_torlite/modules/catalog_pager.html',
kwd = kwd,
cat_slug = cat_slug,
pager_num = page_num,
page_current = current,
)
示例2: render
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,
)
示例3: catalog_of
class catalog_of(tornado.web.UIModule):
def render(self, uid_with_str):
self.mcat = MCatalog()
recs = self.mcat.query_uid_starts_with( uid_with_str )
return self.render_string('tmpl_torlite/modules/catalog_of.html',
recs=recs)
示例4: IndexHandler
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, )
示例5: PageAjaxHandler
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'
示例6: initialize
def initialize(self):
self.init()
self.mpost = MPost()
self.mcat = MCatalog()
self.cats = self.mcat.query_all()
self.mpost2catalog = MPost2Catalog()
self.ysearch = yunsearch()
示例7: CategoryHandler
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()
示例8: get_footer
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)
示例9: ModuleCatMenu
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('doc/modules/menu_post.html',
kwd=kwd)
示例10: initialize
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'
示例11: PostAjaxHandler
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'
示例12: SearchHandler
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,
)
示例13: initialize
def initialize(self):
self.init()
self.mclass = MCatalog()
self.tmpl_router = 'maintain_category'
示例14: MaintainCategoryHandler
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
#.........这里部分代码省略.........
示例15: initialize
def initialize(self):
self.init()
self.mpost = MPost()
self.mcat = MCatalog()
self.mpage = MPage()
self.mlink = MLink()