本文整理汇总了Python中models.blog.Blog类的典型用法代码示例。如果您正苦于以下问题:Python Blog类的具体用法?Python Blog怎么用?Python Blog使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Blog类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _create_new_account
def _create_new_account(self):
title = input("Title of the blog? ")
description = input("Description of the blog? ")
blog = Blog(self.user, title, description)
# no need to create new_post() because we are essentially creating a new account.
blog.save_to_mongo()
self.user_blog = blog
示例2: new_blog
def new_blog(self, title, description):
blog = Blog(author=self.email,
title=title,
description=description,
author_id=self._id)
blog.save_to_mongo()
示例3: _prompt_user_for_account
def _prompt_user_for_account(self):
title = input("Enter blog title: ")
description = input("Enter blog description: ")
blog = Blog(author=self.user,
title=title,
description=description)
blog.save_to_mongo()
self.user_blog = blog
示例4: create_new_blog
def create_new_blog():
if request.method == 'GET':
return render_template('new_blog.html')
else:
title = request.form['title']
description = request.form['description']
user = User.get_by_email(session['email'])
new_blog = Blog(user.email, title, content, user._id)
new_blog.save_to_mongo()
return make_response(user_blogs(user._id))
示例5: new_blog
def new_blog(self, title, description):
"""new_blog(str, str) -> return(None)
title : The title for the new blog
description: The description for the new blog
Creates a new blog.
"""
blog = Blog(author=self.email,
title=title,
description=description,
author_id=self._id)
blog.save()
示例6: _user_exists
def _user_exists(self):
blog = Database.find_one('blogs', {"author": self.user})
if blog is not None:
self.user_blog = Blog.from_mongo(blog['id'])
return True
else:
return False
示例7: _user_has_account
def _user_has_account(self):
blog = Database.find_one("blogs", {"author": self.user})
if blog is not None:
self.user_blog = Blog.from_mongo(blog["id"])
return True
else:
return False
示例8: _user_has_account
def _user_has_account(self):
blog = Database.find_one('blogs', {'author': self.user})
if blog is not None:
self.user_blog = Blog.from_mongo(blog['id']) #si le asigno la variable blog queda la info pero user_blog no seria un objeto. de esta manera traigo el objeto con el metodo from_mongo
return True
else:
return False
示例9: _view_blog
def _view_blog(self):
blog_to_see = input("Enter the ID of the blog you'd write to read: ")
blog = Blog.from_mongo(blog_to_see)
posts = blog.get_posts()
print('----------------------------')
for post in posts:
print("Date: {}, Title: {}\n{}\n----------------------------".format(post['created_date'], post['title'], post['content']))
示例10: get
def get(self, tag_id):
data = {
'title': 'Tag | 博客',
'blogs': Blog.get_blog_by_tag_id(tag_id),
'all_tag': BlogTags.get_all_tags(),
}
self.render('purecss_ui/blog_tag.html', **data)
示例11: blog_posts
def blog_posts(blog_id):
user = User.get_by_email(session['email'])
blogs = user.get_blogs()
blog = Blog.from_mongo(blog_id)
posts = blog.get_posts()
return render_template('posts.html', posts=posts, blog_title=blog.title, blog_id=blog._id,blogs=blogs, email=user.email)
示例12: get
def get(self, request, blog_id):
try:
blog = Blog.objects(id = ObjectId(blog_id)).first()
message = blog.to_json()
except:
message = {"error": "Blog not found"}
return HttpResponse(dumps(message))
示例13: create
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
示例14: blog_show
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)
示例15: blog_create
def blog_create(group_id):
group = Group.get(group_id)
if request.method == 'POST':
title = request.form['blog_title']
content = request.form['blog_content']
id = Blog.create(title, content, get_user().id, group_id)
if not id:
return header_render('blog_create.html', group = group)
return redirect(url_for('blog_show',blog_id = id))
else:
return header_render('blog_create.html', group = group)