本文整理汇总了Python中torlite.model.mcatalog.MCatalog.insert_data方法的典型用法代码示例。如果您正苦于以下问题:Python MCatalog.insert_data方法的具体用法?Python MCatalog.insert_data怎么用?Python MCatalog.insert_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类torlite.model.mcatalog.MCatalog
的用法示例。
在下文中一共展示了MCatalog.insert_data方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MaintainCategoryHandler
# 需要导入模块: from torlite.model.mcatalog import MCatalog [as 别名]
# 或者: from torlite.model.mcatalog.MCatalog import insert_data [as 别名]
#.........这里部分代码省略.........
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[2] == '1' or a.user_name == self.get_current_user():
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,
)
@tornado.web.authenticated
def viewit(self, post_id):
rec = self.mclass.get_by_uid(post_id)
if not rec:
kwd = {
'info': '您要找的分类不存在。',
}
self.render('html/404.html', kwd=kwd)
return False
kwd = {
'pager': '',
'editable': self.editable(),
}
self.render('{0}/maintain_category/category_view.html'.format(self.tmpl_name),
view=rec,
unescape=tornado.escape.xhtml_unescape,
kwd=kwd,
userinfo=self.userinfo,
)
@tornado.web.authenticated
def add_post(self):
if self.userinfo.privilege[1] == '1':
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_post = post_data['uid'][0]
cur_post_rec = self.mclass.get_by_id(id_post)
if cur_post_rec is None:
uid = self.mclass.insert_data(id_post, post_data)
self.redirect('/maintain/category/list'.format(id_post))
@tornado.web.authenticated
def user_add_class(self):
if self.userinfo.privilege[1] == '1':
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()
cur_uid = tools.get_uudd(2)
while self.mclass.get_by_id(cur_uid):
cur_uid = tools.get_uudd(2)
uid = self.mclass.insert_data(cur_uid, post_data)
self.redirect('/maintain/category/list'.format(cur_uid))
@tornado.web.authenticated
def delete(self, del_id):
is_deleted = self.mclass.delete(del_id)
if is_deleted:
self.redirect('/maintain/category/list')
else:
return False
示例2: MaintainCategoryHandler
# 需要导入模块: from torlite.model.mcatalog import MCatalog [as 别名]
# 或者: from torlite.model.mcatalog.MCatalog import insert_data [as 别名]
#.........这里部分代码省略.........
'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,
)
@tornado.web.authenticated
def add_post(self):
if self.userinfo.privilege[1] == '1':
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_post = post_data['uid'][0]
cur_post_rec = self.mclass.get_by_id(id_post)
if cur_post_rec is None:
uid = self.mclass.insert_data(id_post, post_data)
self.redirect('/maintain/category/list'.format(id_post))
@tornado.web.authenticated
def add_catalog(self):
if self.userinfo.privilege[1] == '1':
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()
cur_uid = tools.get_uudd(2)
while self.mclass.get_by_id(cur_uid):
cur_uid = tools.get_uudd(2)
uid = self.mclass.insert_data(cur_uid, post_data)
self.redirect('/maintain/category/list'.format(cur_uid))
@tornado.web.authenticated
def delete_by_uid(self, del_id):
is_deleted = self.mclass.delete(del_id)
if is_deleted:
self.redirect('/maintain/category/list')
else:
return False