Ejemplo n.º 1
0
 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']))
Ejemplo n.º 2
0
 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
Ejemplo n.º 3
0
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())