def _view_blog(self): blog_to_see = input("enter the id of the blog to read") blog = Blog.from_mongo(blog_to_see) posts = blog.get_posts() for post in posts: print("Date: {},title {}\n\n{}".format(post['date'], post['title'], post['content']))
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
from model.blog import Blog from database import Database Database.initialize() blog = Blog(author= "adarsh", title = "Sample title", description="Sample Description") blog.new_post() blog.save_to_mongo() from_database = Blog.from_mongo(blog.id) print(blog.get_post())