本文整理汇总了Python中models.blog.Blog.get方法的典型用法代码示例。如果您正苦于以下问题:Python Blog.get方法的具体用法?Python Blog.get怎么用?Python Blog.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.blog.Blog
的用法示例。
在下文中一共展示了Blog.get方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create
# 需要导入模块: from models.blog import Blog [as 别名]
# 或者: from models.blog.Blog import get [as 别名]
def create(cls, blog_id, content, creator_id):
sql = 'insert into {} (blog_id,content,creator_id) values(%s, %s, %s)'.format(cls.__table__)
params = (blog_id, content, creator_id)
id = store.execute(sql,params)
store.commit()
if id:
blog = Blog.get(blog_id)
blog.add_comment_count(1)
return id
示例2: blog_show
# 需要导入模块: from models.blog import Blog [as 别名]
# 或者: from models.blog.Blog import get [as 别名]
def blog_show(blog_id):
blog = Blog.get(blog_id)
user = get_user()
if not user:
is_join = False
else:
is_join = blog.get_is_join(user.id)
comment_list = Comment.get_comments(blog_id)
return header_render('blog_show.html', blog=blog, comment_list = comment_list,
is_join = is_join)
示例3: delete_post
# 需要导入模块: from models.blog import Blog [as 别名]
# 或者: from models.blog.Blog import get [as 别名]
def delete_post(self, request):
obj = Blog.get(id=request.params[0])
if request.user == obj.author:
obj.delete()
return self.render('blog/list')
示例4: view
# 需要导入模块: from models.blog import Blog [as 别名]
# 或者: from models.blog.Blog import get [as 别名]
def view(self, request):
blog = Blog.get(slug=request.data['slug'])
objects = Article.filter(blog=blog).last('date_create')
return self.render('blog/view', {'objects': objects})
示例5: delete
# 需要导入模块: from models.blog import Blog [as 别名]
# 或者: from models.blog.Blog import get [as 别名]
def delete(self):
sql = 'delete from {} where id=%s'.format(self.__table__)
store.execute(sql, self.id)
store.commit()
blog = Blog.get(self.blog_id)
blog.add_comment_count(-1)