当前位置: 首页>>代码示例>>Python>>正文


Python Blog.from_mongo方法代码示例

本文整理汇总了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
开发者ID:LifeOnAFarm,项目名称:command-line-blog,代码行数:9,代码来源:menu.py

示例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
开发者ID:CodeAmend,项目名称:terminal-blog,代码行数:9,代码来源:menu.py

示例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']))
开发者ID:isabelitagr,项目名称:terminal_blog,代码行数:9,代码来源:menu.py

示例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
开发者ID:isabelitagr,项目名称:terminal_blog,代码行数:9,代码来源:menu.py

示例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)
开发者ID:wmsgood,项目名称:Mongoblog,代码行数:10,代码来源:app.py

示例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)
开发者ID:wmsgood,项目名称:Mongoblog,代码行数:18,代码来源:app.py

示例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)
开发者ID:asimonia,项目名称:web-blog,代码行数:7,代码来源:app.py

示例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']))
开发者ID:Shutirtho,项目名称:simple_blog_running_from_terminal,代码行数:8,代码来源:menu.py

示例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())

开发者ID:kggiorno,项目名称:pythonLearnPublic,代码行数:19,代码来源:app.py

示例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)
开发者ID:wmsgood,项目名称:Mongoblog,代码行数:7,代码来源:user.py

示例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"]))
开发者ID:LifeOnAFarm,项目名称:command-line-blog,代码行数:8,代码来源:menu.py


注:本文中的models.blog.Blog.from_mongo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。