本文整理汇总了Python中torlite.model.mcatalog.MCatalog.get_by_id方法的典型用法代码示例。如果您正苦于以下问题:Python MCatalog.get_by_id方法的具体用法?Python MCatalog.get_by_id怎么用?Python MCatalog.get_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类torlite.model.mcatalog.MCatalog
的用法示例。
在下文中一共展示了MCatalog.get_by_id方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MaintainCategoryHandler
# 需要导入模块: from torlite.model.mcatalog import MCatalog [as 别名]
# 或者: from torlite.model.mcatalog.MCatalog import get_by_id [as 别名]
class MaintainCategoryHandler(BaseHandler):
def initialize(self):
self.init()
self.muser = MUser()
self.mclass = MCatalog()
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('/')
if url_str == 'add':
self.to_add_class()
elif url_str == 'list':
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':
self.user_add_class()
else:
self.redirect('html/404.html')
def recent(self):
kwd = {
'pager': '',
'unescape': tornado.escape.xhtml_unescape,
'title': '最近文档',
}
self.render('{0}/maintain_category/category_list.html'.format(self.tmpl_name),
kwd=kwd,
view=self.mclass.query_recent(),
format_date=tools.format_date,
userinfo=self.userinfo,
)
def refresh(self):
kwd = {
'pager': '',
'title': '最近文档',
}
self.render('{0}/maintain_category/category_list.html'.format(self.tmpl_name),
kwd=kwd,
userinfo=self.userinfo,
view=self.mclass.query_dated(10),
format_date=tools.format_date,
unescape=tornado.escape.xhtml_unescape, )
def get_random(self):
return self.mclass.query_random()
def wiki(self, uid):
dbdate = self.mclass.get_by_id(uid)
if dbdate:
self.viewit(uid)
else:
self.to_add(uid)
def to_add_class(self, ):
kwd = {
'pager': '',
'uid': '',
}
self.render('{0}/maintain_category/category_add.html'.format(self.tmpl_name),
topmenu='',
kwd=kwd,
userinfo=self.userinfo,
)
#.........这里部分代码省略.........
示例2: MaintainCategoryHandler
# 需要导入模块: from torlite.model.mcatalog import MCatalog [as 别名]
# 或者: from torlite.model.mcatalog.MCatalog import get_by_id [as 别名]
class MaintainCategoryHandler(BaseHandler):
def initialize(self):
self.init()
self.muser = MUser()
self.mclass = MCatalog()
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('/')
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)
def post(self, url_str=''):
if url_str == '':
return
url_arr = url_str.split('/')
if url_arr[0] == 'modify':
self.update(url_arr[1])
elif url_str == 'add':
self.add_catalog()
else:
self.redirect('html/404.html')
def list_catalog(self):
kwd = {
'pager': '',
'unescape': tornado.escape.xhtml_unescape,
'title': '最近文档',
}
self.render('{0}/maintain_category/category_list.html'.format(self.tmpl_name),
kwd=kwd,
view=self.mclass.query_all(by_order=True),
format_date=tools.format_date,
userinfo=self.userinfo,
)
@tornado.web.authenticated
def to_add(self):
kwd = {
'pager': '',
'uid': '',
}
self.render('{0}/maintain_category/category_add.html'.format(self.tmpl_name),
topmenu='',
kwd=kwd,
userinfo=self.userinfo,
)
@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()
self.mclass.update(uid, post_data)
self.redirect('/maintain/category/list'.format(uid))
@tornado.web.authenticated
def to_modify(self, id_rec):
a = self.mclass.get_by_id(id_rec)
if self.userinfo.privilege[4] == '1':
pass
else:
return False
kwd = {
'pager': '',
}
self.render('{0}/maintain_category/category_edit.html'.format(self.tmpl_name),
kwd=kwd,
unescape=tornado.escape.xhtml_unescape,
dbrec=a,
userinfo=self.userinfo,
#.........这里部分代码省略.........