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


Python blog.Blog类代码示例

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

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

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

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

示例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()
开发者ID:EgbieAndersonUku1,项目名称:simpleWebBlog,代码行数:13,代码来源:users.py

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

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

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

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

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

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

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

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

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

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


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