本文整理汇总了Python中models.blog.Blog.from_mongo方法的典型用法代码示例。如果您正苦于以下问题:Python Blog.from_mongo方法的具体用法?Python Blog.from_mongo怎么用?Python Blog.from_mongo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.blog.Blog
的用法示例。
在下文中一共展示了Blog.from_mongo方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _user_has_account
# 需要导入模块: from models.blog import Blog [as 别名]
# 或者: from models.blog.Blog import from_mongo [as 别名]
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
示例2: _user_exists
# 需要导入模块: from models.blog import Blog [as 别名]
# 或者: from models.blog.Blog import from_mongo [as 别名]
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
示例3: _view_blog
# 需要导入模块: from models.blog import Blog [as 别名]
# 或者: from models.blog.Blog import from_mongo [as 别名]
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']))
示例4: _user_has_account
# 需要导入模块: from models.blog import Blog [as 别名]
# 或者: from models.blog.Blog import from_mongo [as 别名]
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
示例5: blog_posts
# 需要导入模块: from models.blog import Blog [as 别名]
# 或者: from models.blog.Blog import from_mongo [as 别名]
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)
示例6: user_blogs
# 需要导入模块: from models.blog import Blog [as 别名]
# 或者: from models.blog.Blog import from_mongo [as 别名]
def user_blogs(user_id=None):
if user_id is not None:
user = User.get_by_id(user_id)
else:
user = User.get_by_email(session['email'])
blogs = user.get_blogs()
blog_id = request.args.get('bg')
if blog_id is not None:
blog = Blog.from_mongo(blog_id)
posts = blog.get_posts()
return render_template("user_blogs.html", blogs=blogs, email=user.email,posts=posts, blog_title=blog.title, blog_id=blog._id)
return render_template("user_blogs.html", blogs=blogs, email=user.email)
示例7: blog_posts
# 需要导入模块: from models.blog import Blog [as 别名]
# 或者: from models.blog.Blog import from_mongo [as 别名]
def blog_posts(blog_id):
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)
示例8: _view_blogs
# 需要导入模块: from models.blog import Blog [as 别名]
# 或者: from models.blog.Blog import from_mongo [as 别名]
def _view_blogs(self):
blog_to_see = input("Enter the ID of the blog you would like to read:")
blog = Blog.from_mongo(blog_to_see)
posts = blog.get_posts()
for post in posts:
print("Date: {},title: {}\n\n{}".format(post['created_date'],post['title'],post['content']))
示例9: Blog
# 需要导入模块: from models.blog import Blog [as 别名]
# 或者: from models.blog.Blog import from_mongo [as 别名]
from database import Database
from models.post import Post
from models.blog import Blog
Database.initialize()
blog = Blog(author="Sample Author",
title="KGG's Blog",
description="Sample description")
blog.new_post()
blog.save_to_db()
from_database = Blog.from_mongo(blog.id)
print(blog.get_posts())
示例10: new_post
# 需要导入模块: from models.blog import Blog [as 别名]
# 或者: from models.blog.Blog import from_mongo [as 别名]
def new_post(blog_id, title, content, date=datetime.datetime.utcnow()):
blog = Blog.from_mongo(blog_id)
blog.new_post(title=title,
content=content,
date=date)
示例11: _view_blog
# 需要导入模块: from models.blog import Blog [as 别名]
# 或者: from models.blog.Blog import from_mongo [as 别名]
def _view_blog():
blog_to_see = input("Enter ID of the blog you want to see:")
blog = Blog.from_mongo(blog_to_see)
posts = blog.get_posts()
for post in posts:
print("Date: {}, Title: {},\n\n Content: {}".format(post["created_date"], post["title"], post["content"]))