本文整理匯總了Python中torcms.model.mpost.MPost.insert_data方法的典型用法代碼示例。如果您正苦於以下問題:Python MPost.insert_data方法的具體用法?Python MPost.insert_data怎麽用?Python MPost.insert_data使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類torcms.model.mpost.MPost
的用法示例。
在下文中一共展示了MPost.insert_data方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: PostHandler
# 需要導入模塊: from torcms.model.mpost import MPost [as 別名]
# 或者: from torcms.model.mpost.MPost import insert_data [as 別名]
#.........這裏部分代碼省略.........
tag_infos=self.mcat.query_all(),
userinfo=self.userinfo,
cfg=config.cfg,
)
@tornado.web.authenticated
def to_add(self, uid):
kwd = {
'cats': self.cats,
'uid': uid,
'pager': '',
}
self.render('{0}/{1}/post_add.html'.format(self.tmpl_name, self.tmpl_router),
kwd=kwd,
tag_infos=self.mcat.query_all(),
cfg=config.cfg,
userinfo=self.userinfo, )
@tornado.web.authenticated
def update(self, uid):
raw_data = self.mpost.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()
is_update_time = True if post_data['is_update_time'][0] == '1' else False
self.update_tag(uid)
self.mpost.update(uid, post_data, update_time=is_update_time)
self.update_catalog(uid)
self.mpost_hist.insert_data(raw_data)
self.redirect('/post/{0}.html'.format(uid))
@tornado.web.authenticated
def update_tag(self, signature):
if self.userinfo.privilege[4] == '1':
pass
else:
return False
post_data = {}
for key in self.request.arguments:
post_data[key] = self.get_arguments(key)
if 'tags' in post_data:
pass
else:
return False
current_tag_infos = self.mapp2tag.get_by_id(signature)
tags_arr = [x.strip() for x in post_data['tags'][0].split(',')]
for tag_name in tags_arr:
if tag_name == '':
pass
else:
self.mapp2tag.add_record(signature, tag_name, 1)
for cur_info in current_tag_infos:
if cur_info.tag.name in tags_arr:
pass
else:
self.mapp2tag.remove_relation(signature, cur_info.tag)