• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python model.Comment类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: add_comment

def add_comment():
    
    comment = request.form.get("comment")
    question_id = request.form.get("question_id")

    question_info = Question.query.get(question_id)
    question_author = User.query.filter(User.user_id == question_info.user_id).first()

    date_string = datetime.today().strftime('%Y-%m-%d')
    commented_item = Comment(user_id = session["user_id"], comment_timestamp = date_string, question_id = question_id, comment = comment) 
    db.session.add(commented_item)
    db.session.commit()

    comment_author = User.query.filter(User.user_id == commented_item.user_id).first()
    comment_auth_image = comment_author.images[0]
    

    result = {'comment_id': commented_item.comment_id, 
              'vote': commented_item.vote_count(),
              'comment_author': comment_author.username,
              'comment_auth_image':comment_auth_image.image, 
              'comment_timestamp': commented_item.comment_timestamp,
              'user_id': comment_author.user_id}

    notify_author_comment(commented_item.comment, question_author.email, question_author.username, question_info.question, question_info.title_question, comment_author.username)


    return jsonify(result)
开发者ID:Ihyatt,项目名称:camp_buddy,代码行数:28,代码来源:server.py


示例2: post

    def post(self, id=""):
        act = self.get_argument("act", "")
        if act == "findid":
            eid = self.get_argument("id", "")
            self.redirect("%s/admin/comment/%s" % (BASE_URL, eid))
            return

        tf = {"true": 1, "false": 0}
        post_dic = {
            "author": self.get_argument("author"),
            "email": self.get_argument("email", ""),
            "content": safe_encode(self.get_argument("content").replace("\r", "\n")),
            "url": self.get_argument("url", ""),
            "visible": self.get_argument("visible", "false"),
            "id": id,
        }
        post_dic["visible"] = tf[post_dic["visible"].lower()]

        if MYSQL_TO_KVDB_SUPPORT:
            obj = Comment.get_comment_by_id(id)
            for k, v in obj.items():
                if k not in post_dic:
                    post_dic[k] = v

        Comment.update_comment_edit(post_dic)
        clear_cache_by_pathlist(["post:%s" % id])
        self.redirect("%s/admin/comment/%s" % (BASE_URL, id))
        return
开发者ID:yobin,项目名称:saepy-log,代码行数:28,代码来源:admin.py


示例3: post

    def post(self, postId):

        post = Post.get_post_by_id(postId)
        if not post or post.status != 0 or post.commentstatus == 1:
            self.write('抱歉,评论功能已关闭。')
        else:
            username = self.get_argument('username', '')
            email = self.get_argument('email', '')
            content = self.get_argument('comment', '')
            parentid = int(self.get_argument('parentid', 0))
            if self.islogin:
                curr_user_info = self.get_current_user_info
                username = curr_user_info.username
                email = curr_user_info.email

            if username == '' or content == '' or not isemail(email):
                self.flash(u'错误:称呼、电子邮件与内容是必填项')
                self.redirect(post.url + '#comments')
                return
            username = username[:20]
            content = content[:512]
            if not self.islogin:
                is_spam = spam_check(content, self.request.remote_ip)
            else:
                is_spam = 0
            if is_spam:
                self.flash(u'sorry,your comment is not posted')
                self.redirect(post.url+'#comments')
            location = get_location_byip(self.request.remote_ip)
            Comment.post_comment(postid=postId, username=username, email=email, content=content, parentid=parentid,
                                 ip=self.request.remote_ip, isspam=is_spam, location=location)
            if is_spam:
                self.flash(u'您的评论可能会被认定为Spam')
            self.set_comment_user(username, email)
            self.redirect(post.url + '#comments')
开发者ID:yibin001,项目名称:pyblog,代码行数:35,代码来源:blog.py


示例4: api_comments

def api_comments(*, page='1'):
    page_index = get_page_index(page)
    num = yield from Comment.findNumber('count(id)')
    p = Page(num, page_index)
    if num == 0:
        return dict(page=p, comments=())
    comments = yield from Comment.findAll(orderBy='created_at desc', limit=(p.offset, p.limit))
    return dict(page=p, comments=comments)
开发者ID:wentixiaogege,项目名称:python3,代码行数:8,代码来源:handlers.py


示例5: get

 def get(self):
     page = int(self.get_argument('page', 1))
     if self.get_argument('act', '') == 'delete':
         Comment.delete_comment_by_id(int(self.get_argument('id', 0)))
     pagesize = 20
     rtn = Comment.get_comments(pagesize=pagesize)
     self.datamap['comments'] = rtn[1]
     self.datamap['count'] = rtn[0]
     self.datamap['pagecount'] = int(math.ceil(float(rtn[0]) / pagesize))
     self.write(render_admin.comment(self.datamap))
开发者ID:yibin001,项目名称:pyblog,代码行数:10,代码来源:admin.py


示例6: api_create_comment

def api_create_comment(id, request, *, content):
    user = request.__user__
    if user is None:
        raise APIPermissionError('Please signin first.')
    if not content or not content.strip():
        raise APIValueError('content')
    blog = yield from Blog.find(id)
    if blog is None:
        raise APIResourceNotFoundError('Blog')
    comment = Comment(blog_id=blog.id, user_id=user.id, user_name=user.name, user_image=user.image, content=content.strip())
    yield from comment.save()
    return comment
开发者ID:wentixiaogege,项目名称:python3,代码行数:12,代码来源:handlers.py


示例7: api_craete_commnet

def api_craete_commnet(id, request, content):
	if not id or not id.strip():
		raise APIValueError('id','empty id')
	if not content or not content.strip():
		raise APIValueError('content','empty content')

	commnet = Comment(blog_id=id, user_id=request.__user__.id, user_name=request.__user__.name, user_image=request.__user__.image, content=content)
	yield from commnet.save()

	r = aiohttp.web.Response()
	r.content_type = 'application/json'
	r.body = json.dumps(commnet,ensure_ascii=False).encode('utf-8')
	return r
开发者ID:cinuor,项目名称:MyWebApp,代码行数:13,代码来源:handlers.py


示例8: post

    def post(self):
        if self.user.state == UserState.PROPOSED:
            proposal_key_str = self.request.get('proposal_key_str')
            proposal_key = ndb.Key(urlsafe=proposal_key_str)
            content = self.request.get('content')
            Comment.create_comment(proposal_key, self.user.username, content)

            comments = proposal_key.get().get_comments()
            comments_rendered = ''
            for comment in comments:
                comments_rendered += self.render_str('comment.html', comment=comment)

            self.write(comments_rendered)
        else:
            self.abort(400)
开发者ID:yeonhoyoon,项目名称:atlantis,代码行数:15,代码来源:handlers.py


示例9: post

	def post(self,page):
		code=page.param("code")
		OptionSet.setValue("Akismet_code",code)
		rm=page.param('autorm')
		if rm and int(rm)==1:
			rm=True
		else:
			rm=False
		oldrm = OptionSet.getValue("Akismet_AutoRemove",False)
		if oldrm!=rm:
			OptionSet.setValue("Akismet_AutoRemove",rm)
		spam=page.param("spam")
		spam = len(spam)>0 and int(spam) or 0
		sOther = ""
		if spam>0:
			cm = Comment.get_by_id(spam)
			try:
				url = Blog.all().fetch(1)[0].baseurl
				self.SubmitAkismet({
					'user_ip' : cm.ip,
					'comment_type' : 'comment', 
					'comment_author' : cm.author.encode('utf-8'),
					'comment_author_email' : cm.email,
					'comment_author_url' : cm.weburl,
					'comment_content' : cm.content.encode('utf-8')
				},url,"Spam")
				sOther = u"<div style='padding:8px;margin:8px;border:1px solid #aaa;color:red;'>评论已删除</div>"
				cm.delit()
			except:
				sOther = u"<div style='padding:8px;margin:8px;border:1px solid #aaa;color:red;'>无法找到对应的评论项</div>"
		return sOther + self.get(page)
开发者ID:Alwnikrotikz,项目名称:micolog2,代码行数:31,代码来源:akismet.py


示例10: get

 def get(self, name = ''):
     objs = Tag.get_tag_page_posts(name, 1)
     
     catobj = Tag.get_tag_by_name(name)
     if catobj:
         pass
     else:
         self.redirect(BASE_URL)
         return
     
     allpost =  catobj.id_num
     allpage = allpost/EACH_PAGE_POST_NUM
     if allpost%EACH_PAGE_POST_NUM:
         allpage += 1
         
     output = self.render('index.html', {
         'title': "%s - %s"%( catobj.name, SITE_TITLE),
         'keywords':catobj.name,
         'description':SITE_DECR,
         'objs': objs,
         'cats': Category.get_all_cat_name(),
         'tags': Tag.get_hot_tag_name(),
         'page': 1,
         'allpage': allpage,
         'listtype': 'tag',
         'name': name,
         'namemd5': md5(name.encode('utf-8')).hexdigest(),
         'comments': Comment.get_recent_comments(),
         'links':Link.get_all_links(),
     },layout='_layout.html')
     self.write(output)
     return output
开发者ID:bibodeng,项目名称:pyWeiXin_SAElog,代码行数:32,代码来源:blog.py


示例11: get

    def get(self, name = ''):
        objs = Category.get_cat_page_posts(name, 1)

        catobj = Category.get_cat_by_name(name)
        if catobj:
            pass
        else:
            self.redirect(BASE_URL)
            return

        allpost =  catobj.id_num
        allpage = allpost/EACH_PAGE_POST_NUM
        if allpost%EACH_PAGE_POST_NUM:
            allpage += 1

        output = self.render('index.html', {
            'title': "%s - %s"%( catobj.name, getAttr('SITE_TITLE')),
            'keywords':catobj.name,
            'description':getAttr('SITE_DECR'),
            'objs': objs,
            'cats': Category.get_all_cat_name(),
            'tags': Tag.get_hot_tag_name(),
            'archives': Archive.get_all_archive_name(),
            'page': 1,
            'allpage': allpage,
            'listtype': 'cat',
            'name': name,
            'namemd5': md5(name.encode('utf-8')).hexdigest(),
            'comments': Comment.get_recent_comments(),
            'links':Link.get_all_links(),
            'isauthor':self.isAuthor(),
            'Totalblog':get_count('Totalblog',NUM_SHARDS,0),
        },layout='_layout.html')
        self.write(output)
        return output
开发者ID:yangzilong1986,项目名称:saepy-log,代码行数:35,代码来源:blog.py


示例12: post

    def post(self):
        # this method is reserved for AJAX call to this object
        # json response
        result = {'message': ""}
        comment_id = self.request.POST.get("comment_id", "")
        operation = self.request.POST.get("operation", "")
        logging.info("CommentManager, post data: comment_id = %s, operation = %s" % (comment_id, operation))
        if comment_id:
            comment = Comment.get_by_id(long(comment_id))
            if comment:
                if operation == "delete":
                    # update entry.commentcount
                    comment.entry.commentcount -= 1
                    comment.entry.put()
                    # delete this comment
                    comment.delete()
                    result['message'] = "comment '%s' has been deleted" % (comment_id)
                else:
                    result['message'] = "unknown operation %s" % (operation)
            else:
                result['message'] = "unknown comment id %s" % (comment_id)
        else:
            result['message'] = "empty comment id"

        json_response = json.encode(result)
        logging.info("json response: %s" % (json_response))

        self.response.content_type = "application/json"
        return self.response.out.write(json_response)
开发者ID:loongw,项目名称:another-gae-blog,代码行数:29,代码来源:admin.py


示例13: api_delete_comments

def api_delete_comments(id, request):
    check_admin(request)
    c = yield from Comment.find(id)
    if c is None:
        raise APIResourceNotFoundError('Comment')
    yield from c.remove()
    return dict(id=id)
开发者ID:wentixiaogege,项目名称:python3,代码行数:7,代码来源:handlers.py


示例14: post

    def post(self, post_id):
        post_id = int(post_id)
        post = Post.id(post_id)
        if not post:
            #TODO 404
            return
        
        pdict = self.request.POST
        
        nickname = pdict.get("author")
        email = pdict.get("email")
        website = pdict.get("url")
        comment = pdict.get("comment")
        logging.info(website)

        #def new(cls, belong, nickname, email, author=None, re=None, ip=None, website=None, hascheck=True, commenttype=CommentType.COMMENT):
        try:
            c = Comment.new(belong=post,
                            nickname=nickname,
                            email=email,
                            website=website,
                            content=comment,
                            ip=self.request.client_ip)
        except Exception, ex:
            logging.info(traceback.format_exc())
开发者ID:dreampuf,项目名称:bana,代码行数:25,代码来源:blog_views.py


示例15: update_basic_info

	def update_basic_info(
		update_categories=False,
		update_tags=False,
		update_links=False,
		update_comments=False,
		update_archives=False,
		update_pages=False):

		from model import Entry,Archive,Comment,Category,Tag,Link
		basic_info = ObjCache.get(is_basicinfo=True)
		if basic_info is not None:
			info = ObjCache.get_cache_value(basic_info.cache_key)
			if update_pages:
				info['menu_pages'] = Entry.all().filter('entrytype =','page')\
							.filter('published =',True)\
							.filter('entry_parent =',0)\
							.order('menu_order').fetch(limit=1000)
			if update_archives:
				info['archives'] = Archive.all().order('-year').order('-month').fetch(12)
			if update_comments:
				info['recent_comments'] = Comment.all().order('-date').fetch(5)
			if update_links:
				info['blogroll'] = Link.all().filter('linktype =','blogroll').fetch(limit=1000)
			if update_tags:
				info['alltags'] = Tag.all().order('-tagcount').fetch(limit=100)
			if update_categories:
				info['categories'] = Category.all().fetch(limit=1000)

			logging.debug('basic_info updated')
			basic_info.update(info)
开发者ID:fly2014,项目名称:XBLOG,代码行数:30,代码来源:cache.py


示例16: get

    def get(self, page_slug=""):
        if page_slug:
            t_values = {}

            posts = Entry.all().filter("is_external_page =", True).filter("entrytype =", 'page').filter("slug =", page_slug)
            if posts.count() == 1:
                logging.warning("find one page with slug=%s" % (page_slug))
                posts = posts.fetch(limit=1)
                post = posts[0]
                t_values['post'] = post
                # dump(post)

                # find all comments
                comments = Comment.all().filter("entry =", post).order("date")
                t_values['comments'] = comments
            else:
                logging.warning("%d entries share the same slug %s" % (posts.count(), page_slug))

            links = Link.all().order("date")
            t_values['links'] = links

            categories = Category.all()
            t_values['categories'] = categories

            pages = Entry.all().filter("is_external_page =", True).filter("entrytype =", 'page').order("date")
            t_values['pages'] = pages

            return self.response.out.write(render_template("page.html", t_values, "basic", False))
        else:
            self.redirect(uri_for("weblog.index"))
开发者ID:loongw,项目名称:another-gae-blog,代码行数:30,代码来源:weblog.py


示例17: get

    def get(self, path):
        gdict = self.GET
        path = urllib.unquote(path)
        if path == config.FEED_SRC: #FEED
            self.set_content_type("atom")
            posts = Post.get_feed_post(config.FEED_NUMBER) 
            self.render("feed.xml", {"posts": posts })
            return

        post = Post.get_by_path(path)
        if post:
            p = gdict.get("p", None)
            p = int(p) if p and p.isdigit() else 1

            def post_comment_filter(query):
                query = query.filter("belong =", post)
                if config.COMMENT_NEEDLOGINED:
                    query = query.filter("hashcheck =", True)
                query = query.order("date_created")
                return query

            post_comments = Comment.fetch_page(p, config.COMMENT_PAGE_COUNT, func=post_comment_filter, realtime_count=True)
            context = {"post": post,
                       "post_comments": post_comments, } 
            self.render("single.html", context)
            return 
开发者ID:dreampuf,项目名称:bana,代码行数:26,代码来源:blog_views.py


示例18: get_blog

def get_blog(id):
	blog = yield from Blogs.find('id=?',[id])
	comments = yield from Comment.findAll('blog_id=?',[id],orderby='created_at DESC')
	return {
	'__template__':'blog.html',
	'blog':blog,
	'comments':comments
	}
开发者ID:cinuor,项目名称:MyWebApp,代码行数:8,代码来源:handlers.py


示例19: get

    def get(self, page_id="", operation=""):
        # find all comments, and list all comments
        t_values = {}
        logging.info("CommentManager get")

        # show all comments
        comments = Comment.all().order("entry")
        t_values['comments'] = comments
        return self.response.out.write(render_template("comments.html", t_values, "", True))
开发者ID:loongw,项目名称:another-gae-blog,代码行数:9,代码来源:admin.py


示例20: get

 def get(self, id = ''):
     obj = None
     if id:
         obj = Comment.get_comment_by_id(id)
         if obj:
             act = self.get_argument("act",'')
             if act == 'del':
                 Comment.del_comment_by_id(id)
                 clear_cache_by_pathlist(['post:%d'%obj.postid])
                 self.redirect('%s/admin/comment/'% (BASE_URL))
                 return
     self.echo('admin_comment.html', {
         'title': "管理评论",
         'cats': Category.get_all_cat_name(),
         'tags': Tag.get_all_tag_name(),
         'obj': obj,
         'comments': Comment.get_recent_comments(),
     },layout='_layout_admin.html')
开发者ID:cylinderlee,项目名称:saepy-log,代码行数:18,代码来源:admin.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python model.Credentials类代码示例发布时间:2022-05-27
下一篇:
Python model.Category类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap