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


Python Post.get方法代码示例

本文整理汇总了Python中models.Post.get方法的典型用法代码示例。如果您正苦于以下问题:Python Post.get方法的具体用法?Python Post.get怎么用?Python Post.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Post的用法示例。


在下文中一共展示了Post.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: edit_post

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import get [as 别名]
def edit_post(id):
    if request.forms.update_post :
        post = Post.get(id=id)
        post.title = request.forms.title
        post.content = request.forms.content
        post.save()
        redirect('/view')
    else :
        post = Post.get(id=id)
        return template('templates/edit.html.tpl',post=post)
开发者ID:josuebrunel,项目名称:bottleblog,代码行数:12,代码来源:blog.py

示例2: view_post

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import get [as 别名]
def view_post(id):
    form = request.forms
    if form.update_comment :
        post = Post.get(id=id)
        comment = Comment()
        comment.post = post # current post
        comment.user = User.get(username=form.username)
        comment.content = form.content
        comment.pub_date = datetime.now()
        comment.save()
        redirect('/view/post/%d' %(id,))
    else :
        post = Post.get(id=id)
        comments = Comment.filter(post__id = id)
        return template('templates/post.html.tpl',post=post,comments=comments)
开发者ID:josuebrunel,项目名称:bottleblog,代码行数:17,代码来源:blog.py

示例3: post

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import get [as 别名]
def post(postname):
    post = Post.get(Post.header == postname)
    return render_template('post.html', post=post,
            posts=get_posts(),
            categories=get_categories(),
            recent_posts=get_posts(),
            archives=get_archive())
开发者ID:Zenext,项目名称:Personal-Blog,代码行数:9,代码来源:app.py

示例4: get_update_post

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import get [as 别名]
def get_update_post(id):
    category = Category.select()
    try:
        post = Post.get(id=id)
    except Post.DoesNotExist:
        abort(404)
    return template("admin/update.html", post=post, category=category)
开发者ID:iTriumph,项目名称:MiniAkio,代码行数:9,代码来源:blog.py

示例5: post

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import get [as 别名]
	def post(self):
		postid = self.get_argument('comment_post_ID')
		author = self.get_argument('author',None)
		email = self.get_argument('email',None)
		url = self.get_argument('url',None)
		comment = self.get_argument('comment',None)
		parent_id = self.get_argument('comment_parent',None)

		if postid:
			post = Post.get(id=int(postid))
			if author and email and comment:
				if len(author) >18:
					self.flash('UserName is too long.')
					return self.redirect("%s#respond"%(post.url))
				if not _email_re.match(email):
					self.flash(u'Email address is invalid.')
					return self.redirect("%s#respond"%(post.url))
				if url and not _url_re.match(url):
					self.flash(u'website is invalid.')
					return self.redirect("%s#respond"%(post.url))

				comment = Comment.create(post=post,ip=self.request.remote_ip,
					author=author,email=email,website=url,
					content=comment,parent_id=parent_id)
				self.set_cookie('comment_author',author)
				self.set_cookie('comment_email',email)
				self.set_cookie('comment_website',url)
				return self.redirect(comment.url)
			else:
				self.flash(u"请填写必要信息(姓名和电子邮件和评论内容)")
				return self.redirect("%s#respond"%(post.url))
开发者ID:940825,项目名称:logpress-tornado,代码行数:33,代码来源:blog.py

示例6: edit_post

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import get [as 别名]
def edit_post(id):
    username = request.get_cookie('admin', secret='some-secret-key')
    if username:
        if request.forms.update_post:
            edit_post = Post.get(Post.id==id)
            edit_post.title = request.forms.title
            edit_post.content = request.forms.editor1        
            edit_post.save()
            redirect ('/admin')
        else:
            edit_post = Post.get(Post.id==id)
            title = edit_post.title
            content = edit_post.content
            return template('templates/edit_content.tpl', title=title, content=content)
    else:
        redirect('/login')
开发者ID:inghvar,项目名称:snippy,代码行数:18,代码来源:snippy.py

示例7: delete_post

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import get [as 别名]
def delete_post(id):
    #pdb.set_trace()
    try:
        post = Post.get(id=id)
        post.delete_instance()
        return template('templates/view.html.tpl')
    except :
        redirect('/view')
开发者ID:josuebrunel,项目名称:bottleblog,代码行数:10,代码来源:blog.py

示例8: get

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import get [as 别名]
    def get(self, postid):
        try:
            post = Post.get(id=postid)
        except Post.DoesNotExist:
            raise tornado.web.HTTPError(404)

        category = Category.select()
        self.render('admin/post/update.html', post=post, category=category)
开发者ID:dengmin,项目名称:logpress-tornado,代码行数:10,代码来源:admin.py

示例9: view_post

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import get [as 别名]
def view_post(request, post_id):
	post = Post.get(post_id)
	form = CommentForm(request.POST or None)

	if request.POST:
		if form.is_valid():
			form.cleaned_data['post'] = post_id
			form.save()

	comments = Comment.view('blog_app/comments_by_post', key=post_id)
开发者ID:MyRing,项目名称:RN-Prototype,代码行数:12,代码来源:views.py

示例10: get

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import get [as 别名]
	def get(self,page=1):
		p = self.get_argument('p',None)
		if p:
			post = Post.get(id=int(p))
			post.readnum += 1
			post.save()
			self.render('post.html',post=post)
		else:
			pagination = Pagination(Post.select(),int(page),per_page=8)
			self.render('index.html',pagination=pagination)
开发者ID:940825,项目名称:logpress-tornado,代码行数:12,代码来源:blog.py

示例11: set_favourite

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import get [as 别名]
def set_favourite(id=None):
    # Toggle favourite status for post #id
    try:
        is_favourite = Post.get(Post.id == id).is_favourite
        query = Post.update(is_favourite=not is_favourite).where(Post.id == id)
        query.execute()
    except Post.DoesNotExist:
        return jsonify(**POST_NOT_FOUND)

    # return JSON status OK
    return jsonify(**STATUS_OK)
开发者ID:KyubiSystems,项目名称:Wisewolf,代码行数:13,代码来源:views.py

示例12: edit_post

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import get [as 别名]
def edit_post(request, post_id):
    post = Post.get(post_id)
    form = PostForm(request.POST or None, instance=post)
    
    if form.is_valid():
        post = form.save()
    
    return render_to_response("post_edit.html", {
        "form": form,
        "post": post
    }, context_instance=RequestContext(request))
开发者ID:DrTeePot,项目名称:couchdbkit,代码行数:13,代码来源:views.py

示例13: show

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import get [as 别名]
def show(request,key):
  """Request / -- show all posts."""
  user = users.GetCurrentUser()
  try:
    post=Post.get(db.Key(unquote(key)))
    if post is None:
      return http.HttpResponseNotFound("No Post exists with that key")
    return views.respond(request, user, 'posts/show',
                       {'post': post.to_hash()})
  except(db.BadKeyError):
    return http.HttpResponseNotFound("No Post exists with that key")
开发者ID:oloed,项目名称:talk.org,代码行数:13,代码来源:posts.py

示例14: post_new_comment

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import get [as 别名]
def post_new_comment():
    postid = request.forms.get('postid')
    name = request.forms.get('name').decode('utf-8')
    email = request.forms.get('email').decode('utf-8')
    url = request.forms.get('url').decode('utf-8')
    content = request.forms.get('content').decode('utf-8')
    parent = request.forms.get('parentid')
    check = request.forms.get('check')
    if check != "123456":
        post = Post.get(id=postid)
        redirect("/%s" % post.slug)

    post = Post.get(id=postid)
    post.comm_count = post.comm_count + 1
    comment = Comment.create(post=post, author=escape(name),
                             email=escape(email), url=escape(url),
                             content=escape(content), parent=parent,
                             published=datetime.datetime.now())
    post.save()
    redirect("/%s#comment-%s" % (post.slug, comment.id))
开发者ID:iTriumph,项目名称:MiniAkio,代码行数:22,代码来源:blog.py

示例15: get_favourite

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import get [as 别名]
def get_favourite(id=None):
    # Get favourite status for post #id
    try:
        fav = Post.get(Post.id == id)
    except Post.DoesNotExist:
        return jsonify(**POST_NOT_FOUND)

    # return post fav status as JSON
    resp = jsonify(fav.is_favourite)
    resp.status_code = 200
    return resp
开发者ID:KyubiSystems,项目名称:Wisewolf,代码行数:13,代码来源:views.py


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