本文整理汇总了Python中model.Article.get_article_by_id_edit方法的典型用法代码示例。如果您正苦于以下问题:Python Article.get_article_by_id_edit方法的具体用法?Python Article.get_article_by_id_edit怎么用?Python Article.get_article_by_id_edit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.Article
的用法示例。
在下文中一共展示了Article.get_article_by_id_edit方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from model import Article [as 别名]
# 或者: from model.Article import get_article_by_id_edit [as 别名]
def get(self, id=""):
# try:
if id:
oldobj = Article.get_article_by_id_edit(id)
print "DelPost()", oldobj
if not oldobj:
return
if MYSQL_TO_KVDB_SUPPORT:
oldobj_category = oldobj["category"]
oldobj_archive = oldobj["archive"]
oldobj_tags = oldobj["tags"]
else:
oldobj_category = oldobj.category
oldobj_archive = oldobj.archive
oldobj_tags = oldobj.tags
Category.remove_postid_from_cat(oldobj_category, str(id))
Archive.remove_postid_from_archive(oldobj_archive, str(id))
Tag.remove_postid_from_tags(set(oldobj_tags.split(",")), str(id))
Article.del_post_by_id(id)
increment("Totalblog", NUM_SHARDS, -1)
cache_key_list = ["/", "post:%s" % id, "cat:%s" % quoted_string(oldobj_category)]
clear_cache_by_pathlist(cache_key_list)
clear_cache_by_pathlist(["post:%s" % id])
self.redirect("%s/admin/edit_post/" % (BASE_URL))
示例2: get
# 需要导入模块: from model import Article [as 别名]
# 或者: from model.Article import get_article_by_id_edit [as 别名]
def get(self, id=""):
obj = None
if id:
obj = Article.get_article_by_id_edit(id)
self.echo(
"admin_editpost.html",
{"title": "编辑文章", "cats": Category.get_all_cat_name(), "tags": Tag.get_all_tag_name(), "obj": obj},
layout="_layout_admin.html",
)
示例3: get
# 需要导入模块: from model import Article [as 别名]
# 或者: from model.Article import get_article_by_id_edit [as 别名]
def get(self, id = ''):
obj = None
if id:
obj = Article.get_article_by_id_edit(id)
self.echo('admin_editpost.html', {
'title': "编辑文章",
'cats': Category.get_all_cat_name(),
'tags': Tag.get_all_tag_name(),
'obj': obj
},layout='_layout_admin.html')
示例4: get
# 需要导入模块: from model import Article [as 别名]
# 或者: from model.Article import get_article_by_id_edit [as 别名]
def get(self, id = ''):
try:
if id:
oldobj = Article.get_article_by_id_edit(id)
Category.remove_postid_from_cat(oldobj.category, str(id))
Archive.remove_postid_from_archive(oldobj.archive, str(id))
Tag.remove_postid_from_tags( set(oldobj.tags.split(',')) , str(id))
Article.del_post_by_id(id)
increment('Totalblog',NUM_SHARDS,-1)
cache_key_list = ['/', 'post:%s'% id, 'cat:%s' % quoted_string(oldobj.category)]
clear_cache_by_pathlist(cache_key_list)
clear_cache_by_pathlist(['post:%s'%id])
self.redirect('%s/admin/edit_post/'% (BASE_URL))
except:
pass
示例5: post
# 需要导入模块: from model import Article [as 别名]
# 或者: from model.Article import get_article_by_id_edit [as 别名]
def post(self, id = ''):
act = self.get_argument("act",'')
if act == 'findid':
eid = self.get_argument("id",'')
self.redirect('%s/admin/edit_post/%s'% (BASE_URL, eid))
return
self.set_header('Content-Type','application/json')
rspd = {'status': 201, 'msg':'ok'}
oldobj = Article.get_article_by_id_edit(id)
try:
tf = {'true':1,'false':0}
timestamp = int(time())
post_dic = {
'category': self.get_argument("cat"),
'title': self.get_argument("tit"),
'content': self.get_argument("con"),
'tags': self.get_argument("tag",'').replace(u',',','),
'closecomment': self.get_argument("clo",'0'),
'password': self.get_argument("password",''),
'edit_time': timestamp,
'id': id
}
if post_dic['tags']:
tagslist = set([x.strip() for x in post_dic['tags'].split(',')])
try:
tagslist.remove('')
except:
pass
if tagslist:
post_dic['tags'] = ','.join(tagslist)
post_dic['closecomment'] = tf[post_dic['closecomment'].lower()]
except:
rspd['status'] = 500
rspd['msg'] = '错误: 注意必填的三项'
self.write(json.dumps(rspd))
return
postid = Article.update_post_edit(post_dic)
if postid:
cache_key_list = ['/', 'post:%s'% id, 'cat:%s' % quoted_string(oldobj.category)]
if oldobj.category != post_dic['category']:
#cat changed
Category.add_postid_to_cat(post_dic['category'], str(postid))
Category.remove_postid_from_cat(post_dic['category'], str(postid))
cache_key_list.append('cat:%s' % quoted_string(post_dic['category']))
if oldobj.tags != post_dic['tags']:
#tag changed
old_tags = set(oldobj.tags.split(','))
new_tags = set(post_dic['tags'].split(','))
removed_tags = old_tags - new_tags
added_tags = new_tags - old_tags
if added_tags:
Tag.add_postid_to_tags(added_tags, str(postid))
if removed_tags:
Tag.remove_postid_from_tags(removed_tags, str(postid))
clear_cache_by_pathlist(cache_key_list)
rspd['status'] = 200
rspd['msg'] = '完成: 你已经成功编辑了一篇文章 <a href="/t/%s" target="_blank">查看编辑后的文章</a>' % str(postid)
self.write(json.dumps(rspd))
return
else:
rspd['status'] = 500
rspd['msg'] = '错误: 未知错误,请尝试重新提交'
self.write(json.dumps(rspd))
return
示例6: post
# 需要导入模块: from model import Article [as 别名]
# 或者: from model.Article import get_article_by_id_edit [as 别名]
def post(self, id=""):
act = self.get_argument("act", "")
if act == "findid":
eid = self.get_argument("id", "")
self.redirect("%s/admin/edit_post/%s" % (BASE_URL, eid))
return
self.set_header("Content-Type", "application/json")
rspd = {"status": 201, "msg": "ok"}
oldobj = Article.get_article_by_id_edit(id)
try:
tf = {"true": 1, "false": 0}
timestamp = int(time())
post_dic = {
"category": self.get_argument("cat"),
"title": self.get_argument("tit"),
"content": self.get_argument("con"),
"tags": self.get_argument("tag", "").replace(u",", ","),
"closecomment": self.get_argument("clo", "0"),
"password": self.get_argument("password", ""),
"edit_time": timestamp,
"id": id,
}
if post_dic["tags"]:
tagslist = set([x.strip() for x in post_dic["tags"].split(",")])
try:
tagslist.remove("")
except:
pass
if tagslist:
post_dic["tags"] = ",".join(tagslist)
post_dic["closecomment"] = tf[post_dic["closecomment"].lower()]
except:
rspd["status"] = 500
rspd["msg"] = "错误: 注意必填的三项"
self.write(json.dumps(rspd))
return
postid = Article.update_post_edit(post_dic)
if postid:
cache_key_list = ["/", "post:%s" % id, "cat:%s" % quoted_string(oldobj.category)]
if oldobj.category != post_dic["category"]:
# cat changed
Category.add_postid_to_cat(post_dic["category"], str(postid))
Category.remove_postid_from_cat(post_dic["category"], str(postid))
cache_key_list.append("cat:%s" % quoted_string(post_dic["category"]))
if oldobj.tags != post_dic["tags"]:
# tag changed
old_tags = set(oldobj.tags.split(","))
new_tags = set(post_dic["tags"].split(","))
removed_tags = old_tags - new_tags
added_tags = new_tags - old_tags
if added_tags:
Tag.add_postid_to_tags(added_tags, str(postid))
if removed_tags:
Tag.remove_postid_from_tags(removed_tags, str(postid))
clear_cache_by_pathlist(cache_key_list)
rspd["status"] = 200
rspd["msg"] = '完成: 你已经成功编辑了一篇文章 <a href="/t/%s" target="_blank">查看编辑后的文章</a>' % str(postid)
self.write(json.dumps(rspd))
return
else:
rspd["status"] = 500
rspd["msg"] = "错误: 未知错误,请尝试重新提交"
self.write(json.dumps(rspd))
return