本文整理汇总了Python中models.Blog.get方法的典型用法代码示例。如果您正苦于以下问题:Python Blog.get方法的具体用法?Python Blog.get怎么用?Python Blog.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Blog
的用法示例。
在下文中一共展示了Blog.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: api_delete_blog
# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import get [as 别名]
def api_delete_blog(blog_id):
check_admin()
blog = Blog.get(blog_id)
blog = Blog.get(blog_id)
if blog is None:
raise APIResourceNotFoundError("Blog")
blog.delete()
return dict(id=blog_id)
示例2: blog
# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import get [as 别名]
def blog(blog_id):
blog = Blog.get(blog_id)
if blog is None:
raise notfound()
blog.html_content = markdown2.markdown(blog.content) # change content to html form
comments = Comment.find_by('where blog_id=? order by created_at desc limit 1000', blog_id)
return dict(blog=blog, comments=comments, user=ctx.request.user)
示例3: api_delete_blog
# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import get [as 别名]
def api_delete_blog(bid):
# check_admin()
blog = Blog.get(bid)
if blog is None:
raise APIResourceNotFoundError('Blog not found')
blog.delete()
return dict(id=bid)
示例4: api_edit_blog
# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import get [as 别名]
def api_edit_blog(id):
check_admin()
i = ctx.request.input()
logging.info(i)
title = i.title.strip()
content = i.content.strip()
image = i.image
tags = i.tags
try:
tag_checkbox = ctx.request.gets('tag_checkbox')
except KeyError:
tag_checkbox = []
logging.info("##################")
logging.info(tag_checkbox)
if not title:
raise APIValueError('name', 'name cannot be empty.')
if not content:
raise APIValueError('content', 'content cannot be empty.')
blog = Blog.get(id)
if not blog:
raise notfound()
blog.title = title
blog.content = content
if image:
delete_upload(blog.image)
filename = upload(image)
blog.image = filename
blog.update()
update_tags(blog,tag_checkbox,tags.split(' '))
raise seeother('/blog/%s' % blog.id)
示例5: manage_blogs_edit
# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import get [as 别名]
def manage_blogs_edit(blog_id):
'''管理_修改日志页 GET VIEW'''
blog = Blog.get(blog_id)
if blog is None:
raise notfound()
print 'GET VIEW /manage/blogs/edit/:blog_id dict = %s' % dict(id=blog.id, name=blog.name, summary=blog.summary, content=blog.content, action='/api/blogs/%s' % blog_id, redirect='/manage/blogs', user=ctx.request.user)
return dict(id=blog.id, name=blog.name, summary=blog.summary, content=blog.content, action='/api/blogs/%s' % blog_id, redirect='/manage/blogs', user=ctx.request.user)
示例6: blog
# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import get [as 别名]
def blog(blog_id):
blog = Blog.get(blog_id)
if blog is None:
raise notfound()
#对从数据库中查出的blog内容进行makedown语法格式化
blog.html_content = markdown2.markdown(blog.content)
comments = Comment.find_by('where blog_id=? order by created_at desc limit 100', blog_id)
return dict(blog=blog, comments=comments, user=ctx.request.user)
示例7: api_delete_blog
# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import get [as 别名]
def api_delete_blog(blog_id):
'''删除日志 POST API'''
check_admin()
blog = Blog.get(blog_id)
if blog is None:
raise APIResourceNotFoundError('Blog')
blog.delete()
return dict(id=blog_id)
示例8: blog
# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import get [as 别名]
def blog(blog_id):
import pdb
pdb.set_trace()
blog = Blog.get(blog_id)
if blog is None:
raise notfound()
blog.html_content = markdown2.markdown(blog.content)
comments = Comment.find_by('where blog_id=? order by created_at desc limit 1000',blog_id)
return dict(blog=blog, comments=comments, user=ctx.request.user)
示例9: tasks_sync_click
# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import get [as 别名]
def tasks_sync_click():
keys = kv.get("dirty").split(" ")
keys = [k for k in keys if k]
dirty = kv.get_multi(keys)
for k, v in dirty.iteritems():
print "key: %s,value: %d\n" % (k, v)
blog = Blog.get(k)
blog.click = v
blog.update()
kv.replace("dirty", "")
示例10: blog
# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import get [as 别名]
def blog(id):
blog = Blog.get(id)
if not blog:
raise notfound()
blog.content = markdown2.markdown(blog.content,extras=["code-friendly"])
if 'SERVER_SOFTWARE' not in os.environ:
blog.image = '/'+blog.image
tags = get_tags_from_blog(blog)
blog.tags = tags
tags = all_tags()
return dict(blog=blog,user=ctx.request.user,tags=tags)
示例11: generate_initial_data
# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import get [as 别名]
def generate_initial_data(self):
blog=Blog.get()
dict={
'title':blog.title,
'subtitle':blog.subtitle,
'blognotice':blog.blognotice,
'sitekeywords':blog.sitekeywords,
'sitedescription':blog.sitedescription,
'email':blog.email
}
return dict
示例12: get_form_object
# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import get [as 别名]
def get_form_object(self):
if not self.is_valid():
raise ValueError("valid forms")
blog = Blog.get()
blog.title=self.cleaned_data['title']
blog.subtitle=self.cleaned_data['subtitle']
blog.blognotice=self.cleaned_data['blognotice']
blog.sitekeywords=self.cleaned_data['sitekeywords']
blog.sitedescription=self.cleaned_data['sitedescription']
blog.email=self.cleaned_data['email']
return blog
示例13: delete_blog
# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import get [as 别名]
def delete_blog(id):
check_admin()
blog = Blog.get(id)
if not blog:
raise notfound()
tags = get_tags_from_blog(blog)
remove = [tag.id for tag in tags]
remove_blogtag(blog,remove)
delete_upload(blog.image)
blog.delete()
return {'data':'/'}
示例14: show
# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import get [as 别名]
def show(request, key):
context = base_context()
blog = Blog.get(key)
if not admin():
blog.browsed_count += 1
blog.put()
comments = blog.comment_set.order("date")
form = CommentForm()
context.blog = blog
context.comments = comments
context.form = form
template = loader.get_template("blogs/show.html")
return HttpResponse(template.render(context))
示例15: manage_blogs_edit
# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import get [as 别名]
def manage_blogs_edit(blog_id):
blog = Blog.get(blog_id)
if blog is None:
raise notfound()
return dict(
id=blog.id,
name=blog.name,
summary=blog.summary,
content=blog.content,
action="/api/blogs/%s" % blog_id,
redirect="/manage/blogs",
user=ctx.request.user,
)