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


Python Comment.get方法代码示例

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


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

示例1: createComment

# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import get [as 别名]
    def createComment(self, request):
        """Create new Comment object, returning CommentForm/request."""
        
        author = self._getAuthorFromUser()
        data['authorName'] = author.displayName
        data['authorID'] = author.authorID

        self._checkComment(request)

        data = {'comment': request.comment}

        # get the article key for where the comment will be added
        article_key = self._checkKey(request.websafeArticleKey, 'Article')

        comment_id = Comment.allocate_ids(size=1, parent=article_key)[0]
        comment_key = ndb.Key(Comment, comment_id, parent=article_key)
        data['key'] = comment_key

        # create Comment
        comment_key = Comment(**data).put()

        # send alerts to all authors of Article and all other comments
        #taskqueue.add(params={'email': author.mainEmail,
        #    'CommentInfo': repr(request)},
        #    url='/tasks/send_comment_alert'
        #)

        return self._copyCommentToForm(comment_key.get(), article_key=article_key, author=author)
开发者ID:dansalmo,项目名称:new-aca,代码行数:30,代码来源:aca.py

示例2: api_delete_comment

# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import get [as 别名]
def api_delete_comment(comment_id):
	check_admin()
	comment = Comment.get(comment_id)
	if comment is None:
		raise APIResourceNotFoundError('Comment')
	comment.delete()
	return dict(id=comment_id)
开发者ID:dasbindus,项目名称:my-python-webapp,代码行数:9,代码来源:urls.py

示例3: post

# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import get [as 别名]
    def post(self):
        item = None
        vals = {}
        try:
            # get all the incoming values
            name = self.request.get('name')
            email = self.request.get('email')
            website = self.request.get('website')
            comment = self.request.get('comment')

            if self.request.get('key'):
                item = Comment.get( self.request.get('key') )
                item.name = name
                item.email = email
                item.website = website
                item.comment = comment
            else:
                # we have no ability to add comments, so fail here
                raise error.RequiresEntityError("Needs a comment key (ie. can't add new comments in the admin interface)")

            # update and save this comment
            item.set_derivatives()
            item.put()

            # don't need to item.node.regenerate() since the status is _not_ changing

            self.redirect('.')
        except Exception, err:
            vals['item'] = self.request.POST
            vals['err'] = err
            vals['sections'] = Section.all()
            vals['types'] = models.type_choices
            self.template( 'comment-form.html', vals, 'admin' );
开发者ID:ranginui,项目名称:kohacon,代码行数:35,代码来源:comment.py

示例4: get

# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import get [as 别名]
    def get(self):
        # see if there is a key
        comment = None
        status = None
        try:
            comment = Comment.get( self.request.get('key') )
            status = self.request.get('status')
        except db.BadKeyError:
            pass

        if comment is None:
            # show all the 'new' comments
            comments = Comment.all().filter('status =', 'new').order('inserted').fetch(page_count+1)
            more = True if len(comments) > page_count else False
            comments = comments[:page_count]
            vals = {
                'comments' : comments,
                'more'     : more,
                }
            self.template( 'comment-list.html', vals, 'admin' )
        else:
            comment.status = status_map[status]
            comment.put()
            comment.node.regenerate()
            self.redirect('./')
            return
开发者ID:ranginui,项目名称:kohacon,代码行数:28,代码来源:comment.py

示例5: vote_comment

# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import get [as 别名]
def vote_comment(comment_key,up_or_down):
	vote = 1 if up_or_down == "up" else -1
	comment = Comment.get(comment_key)
	if check_for_user_vote(comment, vote):
		comment.votes = comment.votes + vote
		comment.put()
	votes = comment.votes
	return jsonify(votes=votes)
开发者ID:hm1021,项目名称:webbattle,代码行数:10,代码来源:views.py

示例6: ajax_comment

# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import get [as 别名]
def ajax_comment():
    Comment.create(
        user_id=session["user_id"],
        message_id=int(request.form['message_id']),
        content=request.form['comment_text']
    )
    comment = Comment.get(Comment.content == request.form["comment_text"])
    comment_info = session['first_name'] + " " + session['last_name'] + " - "
    comment_info += comment.created_at.strftime("%B %d %Y")
    comment_dict = {
        "comment": comment.content,
        "comment_info": comment_info,
    }
    return jsonify(comment_dict)
开发者ID:LawerenceLee,项目名称:coding_dojo_projects,代码行数:16,代码来源:app.py

示例7: get

# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import get [as 别名]
    def get(self):
        path = urllib.unquote(self.request.path)
        m = parts.search(path)

        if m is None:
            self.error(404)
            return

        this_path = m.group(1)
        this_page = m.group(3) or 'index'
        this_ext = m.group(4) or 'html'

        if this_page is None:
            this_page = 'index'
            this_ext = 'html'

        section = Section.all().filter('path =', this_path).get()
        if section is None:
            self.error(404)
            return

        # if this is an index, call a different template
        if this_page == 'index' and this_ext == 'html':
            # index.html
            vals = {
                'page'    : 'index.html',
                'section' : section,
                }
            self.template(  section.layout + '-index.html', vals, util.config_value('Theme') );

        elif this_page == 'rss20' and this_ext == 'xml':
            # rss20.xml
            nodes = self.latest_nodes(section, 'index-entry', 10)
            vals = {
                'page'    : 'rss20.xml',
                'section' : section,
                'nodes'   : nodes,
                }
            self.response.headers['Content-Type'] = 'application/rss+xml'
            self.template( 'rss20.xml', vals, 'rss' );

        elif this_page == 'sitefeed' and this_ext == 'xml' and section.has('sitefeed'):
            # sitefeed.xml
            nodes = Node.all().filter('attribute =', 'index-entry').order('-inserted').fetch(10)
            vals = {
                'page'    : 'sitefeed.xml',
                'section' : section,
                'nodes'   : nodes,
                }
            self.response.headers['Content-Type'] = 'application/rss+xml'
            self.template( 'rss20.xml', vals, 'rss' );

        elif this_page == 'sitemapindex' and this_ext == 'xml':
            # sitemapindex.xml
            vals = {
                'page'    : 'sitemapindex.xml',
                'sections' : Section.all().filter('attribute =', 'sitemap-entry').order('inserted'),
                }
            self.response.headers['Content-Type'] = 'text/xml'
            self.template( 'sitemapindex.xml', vals, 'sitemaps' );

        elif this_page == 'urlset' and this_ext == 'xml':
            # urlset.xml
            vals = {
                'page'    : 'urlset.xml',
                'section' : section,
                'nodes'   : Node.all().filter('section =', section.key()).filter('attribute =', 'index-entry').order('inserted')
                }
            self.response.headers['Content-Type'] = 'text/xml'
            self.template( 'urlset.xml', vals, 'sitemaps' );

        elif label_page.search(this_page) and this_ext == 'html':
            # path =~ 'label:something.html'
            m = label_page.search(this_page)
            label = m.group(1)
            vals = {
                'page'    : 'label:' + label + '.html',
                'section' : section,
                'nodes'   : Node.all().filter('section =', section.key()).filter('label =', label).order('-inserted'),
                'label'   : label
                }
            self.template( 'label-index.html', vals, util.config_value('Theme') );

        elif archive_page.search(this_page) and this_ext == 'html':
            # path =~ 'archive:2009.html'
            m = archive_page.search(this_page)
            archive = m.group(1)
            vals = {
                'page'    : 'archive:' + archive + '.html',
                'section' : section,
                'nodes'   : Node.all().filter('section =', section.key()).filter('archive =', archive).order('-inserted'),
                'archive' : archive
                }
            self.template( 'archive-index.html', vals, util.config_value('Theme') );

        elif this_page == 'comment' and this_ext == 'html':
            # get the comment if it exists
            try:
                comment = Comment.get( self.request.get('key') )
            except db.BadKeyError:
#.........这里部分代码省略.........
开发者ID:ranginui,项目名称:kohacon,代码行数:103,代码来源:lollysite.py

示例8: get

# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import get [as 别名]
	def get(self,comment, slug):
		comment = Comment.get(id=int(comment))
		comment.delete_instance()
		
		return redirect(url_for('posts.detail', slug=slug))
开发者ID:Michael-Jalloh,项目名称:atom,代码行数:7,代码来源:views.py

示例9: deleteComment

# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import get [as 别名]
def deleteComment(request, blog_key, comment_key):
    if not admin():
        return HttpResponseRedirect(users.create_login_url("/blogs"))
    comment = Comment.get(comment_key)
    comment.delete()
    return HttpResponseRedirect("/blog/" + blog_key + "/show")
开发者ID:proming,项目名称:myblogongae,代码行数:8,代码来源:views.py

示例10: del_comment

# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import get [as 别名]
def del_comment(id):
    comment = Comment.get(id=id)
    comment.post.comm_count = comment.post.comm_count - 1
    comment.post.save()
    Comment.delete().where(id=id).execute()
    redirect("/admin/comment")
开发者ID:iTriumph,项目名称:MiniAkio,代码行数:8,代码来源:blog.py

示例11: remove_comment

# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import get [as 别名]
def remove_comment(key,battlekey):
	comment = Comment.get(key)
	if comment.author != users.get_current_user():
		return redirect('/battles/'+battlekey)
	db.delete(comment)
	return redirect('/battles/'+battlekey)
开发者ID:hm1021,项目名称:webbattle,代码行数:8,代码来源:views.py


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