本文整理汇总了Python中torlite.model.mspec.SpesubModel.delete方法的典型用法代码示例。如果您正苦于以下问题:Python SpesubModel.delete方法的具体用法?Python SpesubModel.delete怎么用?Python SpesubModel.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类torlite.model.mspec.SpesubModel
的用法示例。
在下文中一共展示了SpesubModel.delete方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SpecialHandler
# 需要导入模块: from torlite.model.mspec import SpesubModel [as 别名]
# 或者: from torlite.model.mspec.SpesubModel import delete [as 别名]
class SpecialHandler(BaseHandler):
def initialize(self):
self.init()
self.muser = MUser()
self.mpage = MPage()
self.mpost = 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, url_str=""):
url_arr = self.parse_url(url_str)
if url_str == '':
self.index()
elif url_str == 'add':
self.to_add()
elif len(url_arr) == 1:
self.list(url_str)
elif len(url_arr) == 2 and url_arr[1] == 'edit':
self.to_edit(url_arr[0])
elif url_arr[0] == 'delete':
self.delete(url_arr[1])
else:
self.render('html/404.html')
def post(self, url_str=''):
url_arr = self.parse_url(url_str)
if url_str == 'add':
self.add()
elif len(url_arr) == 2 and url_arr[1] == 'edit':
self.edit(url_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)
if 'slug' in post_data:
pass
else:
self.set_status(400)
return False
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)
if self.mspec.get_by_slug(post_data['slug'][0]) is None:
self.mspec.addata(post_data)
else:
self.set_status(400)
return False
@tornado.web.authenticated
def to_edit(self, uid):
spec_rec = self.mspec.get_by_id(uid)
self.render('{0}/spec/edit.html'.format(self.tmpl_name), spec_rec=spec_rec,
cfg = config.cfg,
)
@tornado.web.authenticated
def to_add(self):
self.render('{0}/spec/add.html'.format(self.tmpl_name))
def list(self, spec_slug):
'''
列出专题信息,按某一分类
'''
page_rec = self.mspec.get_by_slug(spec_slug)
kwd = {
'editable': self.editable()
}
self.render('{0}/spec/list.html'.format(self.tmpl_name),
kwd=kwd,
spec=page_rec,
unescape=tornado.escape.xhtml_unescape,
spec_recs=self.mpost.query_by_spec(page_rec.uid),
cfg = config.cfg,
)
def index(self):
kwd = {
'editable': self.editable()
}
self.render('{0}/spec/index.html'.format(self.tmpl_name),
#.........这里部分代码省略.........