def news_comment(): news_id = request.form.get('news_id') #新闻ID news_comment = request.form.get('comment') #用户输入的评论到具体内容 user_id = session.get('user_id') #用户ID c = Comment(news_id = news_id ,user_id = user_id,content=news_comment) #生成一条评论表对应的数据 db.session.add(c) #将评论写入到数据库 db.session.commit() #提交 msg={} msg['code'] = '200' msg['data'] = c.to_dict() return jsonify(msg)
def delete(self, post_id): blog = Blog.get_by_id(int(post_id)) comment = Comment.get_by_id(int(self.request.get("id"))) cookie_val = self.request.cookies.get("user_id") if not self.blog_exists(blog): message = "Invalid. The blog page does not exist." self.send_response(404, message) return if not self.comment_exists(comment): message = "Invalid. The comment does not exist." self.send_response(400, message) return if not self.is_signed_in(cookie_val): message = "Invalid. Must be signed in to edit comment." self.send_response(401, message) return if not self.is_author(cookie_val, comment): message = "Invalid. Must be its author to edit this." self.send_response(403, message) return comment.delete() message = json.dumps( {"success": "The comment has been deleted successfully."}) self.send_response(200, message)
def getpost(post_id): if redirect_is_not_logged(session) != True: return redirect_is_not_logged(session) post_exist = Post.query.filter_by(id=post_id).first() if post_exist is not None: page_name = post_exist.title if request.method == 'POST': message = request.form.get('message', None) if message: comment = Comment(message=message, user_id=session['id'], post_id=post_id, created=datetime.datetime.now()) db.session.add(comment) db.session.commit() get_post = db.session.execute( 'SELECT post.* , user.full_name , user.profil_media , user.username , count(DISTINCT jaime.id) as nb_like , count(DISTINCT jaime2.id) as liked, count(DISTINCT comment.id) as nb_comment , strftime(\'%d/%m/%Y %H:%M\', datetime(post.created)) as created FROM post LEFT JOIN comment ON comment.post_id = post.id LEFT JOIN jaime ON jaime.post_id = post.id LEFT JOIN jaime as jaime2 ON jaime2.post_id = post.id AND jaime2.user_id = :myid JOIN user ON user.id = post.user_id LEFT JOIN Followerfollowing ON Followerfollowing.user_id = :myid LEFT JOIN Followerfollowing as Followerfollowing_2 ON Followerfollowing_2.user_id_2 = :myid WHERE post.id = :post_id', { 'myid': session['id'], 'post_id': post_id }).first() get_comments = db.session.execute( 'SELECT comment.* , user.profil_media , user.full_name , user.username , strftime(\'%d/%m/%Y %H:%M\', datetime(comment.created)) as created FROM comment JOIN user ON user.id = comment.user_id WHERE comment.post_id = :post_id ORDER BY created DESC', {'post_id': post_id}) return render_template('post.html', page_name=page_name, Post=get_post, Comments=get_comments) else: return redirect(url_for('index'))
def addComment(): post_data = request.get_json() body = post_data.get('body') article_id = db.session.query(Article).filter( Article.article_url == post_data.get('article_url')).all() if (article_id == []): response_object = { 'status': 'Failure', 'message': "Article Url " + post_data.get('article_url') + " does not exist" } return jsonify(response_object), 404 authenticated = False if request.authorization == None else verify_password( request.authorization.username, request.authorization.password) owner_id = None if authenticated == False else db.session.query( User).filter( User.username == request.authorization.username).all()[0].id db.session.add( Comment(body=body, article_id=article_id[0].id, owner_id=owner_id)) db.session.commit() response_object = { 'status': 'success', 'message': "Comment" + body + " was added!" } return jsonify(response_object), 201
def post(self): # Retrieve posted data body = self.request.get('body') comment = Comment.get_by_id((self.request.get('commentid'))) if comment is None: return self.respond_with_404() if (self.user is None or self.user.username != comment.author_username): return self.redirect(comment.parent_post.permalink) # Verify data if not body: error = 'Your comment cannot be empty!' else: error = None # Handle invalid edit if error: self.response.out.write(self.template.render( user=self.user, body=body, error=error)) else: comment.body = body comment.last_edited = datetime.datetime.utcnow() comment.put() return self.redirect(comment.parent_post.permalink)
def main(): number_comments = 0 check_inbox() delete_if_downvoted() comments = reddit.subreddit('test').comments(limit=100) for comment in comments: regex = re.search(MEMORABLE_QUOTE_REGEX, comment.body) subname = comment.subreddit.display_name allowed = not select(b for b in Bannedsub if b.name == subname)[:] fresh = not select(c for c in Comment if c.id == comment.id)[:] if regex and allowed and fresh: # select a random person from db and create image person = select(x.name for x in Historicalfigure)[:][int(random() * numfigs)] number_comments = number_comments + 1 image = build_image(regex.group(0), comment.id, person) Comment(id=comment.id, url=image) comment.reply(make_comment(image)) print( regex.group(0) + '\n' + '-_-_-' + comment.subreddit.display_name + '\n' + comment.permalink + '\n') print('NEXT')
async def post(self): body = self.loads_request_body() self.session.add( Comment(idArticle=body["idArticle"], content=body["content"], author=body["author"], createdAt=datetime.utcnow())) self.session.commit()
def get(self, topicid): template = jinja_environment.get_template('templates/topic.html') topic = Topic.get_by_id(int(topicid)) if topic: comments = Comment.all().filter('topic',topic) self.response.out.write(template.render({"topic": topic,"comments":comments})) else: self.response.out.write("no topic")
def get(self): comment = Comment.get_by_id(self.request.get('commentid')) if comment is None: return self.respond_with_404() if (self.user is None or self.user.username != comment.author_username): return self.redirect(comment.parent_post.permalink) self.response.out.write(self.template.render(user=self.user, editingcomment=comment))
def addComment(post_id): user = find_logged_user() post = find_post(post_id) comment = Comment(user_id=user.id, post_id=post.id, content=request.form['content'], date_added=datetime.datetime.now()) session.add(comment) session.commit() return redirect('/showpost/%s#comments' % post_id)
def artcle(url,url2): ''' Article driver for all generic article pages. ''' if request.method == 'POST': if 'title' in request.form and 'message' in request.form: z = Comment(title=request.form['title'],message=request.form['message'],poster=current_user.id,postername = current_user.name, article=url2) db.session.add(z) db.session.commit() post = Post.query.filter_by(topic=url,id=url2).first() if post: return render_template('article.html',art = post,title=post.title,pidd=post.id) addAttack(request.url) return render_template('genericpage.html',body='Article not found!',title='Error')
def post(self, post_id): data = json.loads(self.request.body) cookie_val = self.request.cookies.get("user_id") blog = Blog.get_by_id(int(post_id)) title = data["title"] content = data["content"] user = User.get_by_id(int(cookie_val.split("|")[0])) if not self.blog_exists(blog): message = "Invalid. The requested page doesn't exist." self.send_response(404, message) return if not self.is_signed_in(cookie_val): message = "Invalid. Only signed in User can post comments" self.send_response(401, message) return if not (title and content): message = "Invalid. Title and texts must not be empty." self.send_response(400, message) return comment = Comment(title=title, content=content, blog=blog, author=user) comment_id = comment.put().id() message = json.dumps({ "success": "Comment successfully added to database.", "id": comment_id, "title": title, "content": content, "author": user.username, "date_created": comment.date_created.strftime("%B %d %Y %I:%M%p") }) self.send_response(200, message)
def post(self): # Ensure that the comment exists, and the user owns the comment comment = Comment.get_by_id(self.request.get('commentid')) if comment is None: return self.respond_with_404() if (self.user is None or self.user.username != comment.author_username): return self.redirect(comment.parent_post.permalink) # Grab the parent post permalink before deleting redirect_location = comment.parent_post.permalink # Delete comment.key.delete() # Redirect back to parent post permalink return self.redirect(redirect_location)
def personal_profile(): username = request.get_json().get('username') res = User.through_username(username) user_id = res[0].user_id register_time = res[0].create_time msg_count = len(Message.find_by_user(user_id)) comment_count = Comment.count_self_comment(user_id) dic = { 0: register_time, 1: msg_count, 2: comment_count } return dic
def add_comment(): content = request.form.get('comment_content') note_id = request.form.get('note_id') comment = Comment(content=content) user_id = session['user_id'] user = User.query.filter(User.id == user_id).first() comment.author = user note = Note.query.filter(Note.id == note_id).first() comment.note = note db.session.add(comment) db.session.commit() return redirect(url_for('note.detail', note_id=note_id))
def get(self, post_id): cookie_val = self.request.cookies.get("user_id") blog = Blog.get_by_id(int(post_id)) comments = (Comment.all().filter("blog =", blog.key()).order("-date_created")) # Determine whether to insert 'Login' or 'Logout' button. if (self.is_signed_in(cookie_val)): self.render("readBlog.html", blog=blog, signed_in=True, comments=comments) # Insert login button else: self.render("readBlog.html", blog=blog, comments=comments)
def get(self, post_id): cookie_val = self.request.cookies.get("user_id") comment = Comment.get_by_id(int(self.request.get("id"))) if not self.is_signed_in(cookie_val): message = "Invalid. User must be signed-in to edit this comment." self.send_response(401, message) return if not self.is_author(cookie_val, comment): message = "Invalid. Only its author is allowed to edit." self.send_response(403, message) return message = json.dumps({"success": "Allowed"}) self.send_response(200, message)
def post(self): # Ensure that the post exists, and the user owns the post post = BlogPost.get_by_id(self.request.get('postid')) if post is None: return self.respond_with_404() if (self.user is None or self.user.username != post.author_username): return self.redirect(post.permalink) # Delete all child comments query = Comment.query(ancestor=post.key) for comment in query.fetch(): comment.key.delete() # Delete the post itself post.key.delete() # Redirect to homepage return self.redirect('/')
def setup(self, *args, **kwargs): self.ids.dialog_author.text = self.thread.author.username self.ids.dialog_author.secondary_text = str(self.thread.date) if self.thread.description: self.ids.dialog_description.text = self.thread.description if self.thread.image: self.ids.dialog_img.source = f"media/thread/{self.thread.id}.png" self.ids.dialog_likes.text = str(self.thread.likes) print(self.thread.comments) comments = self.thread.comments self.ids.dialog_comments.text = f"Comments({len(comments) if comments else 0})" self.ids.dialog_like_btn.on_press = lambda: like_post( self.thread, self, "dialog_likes") self.ids.comment_submit.on_press = lambda: self.add_comment( self.ids.coment_message.text) if comments: self.ids.comments.clear_widgets() for comment in comments: self.ids.comments.add_widget(Comment(comment))
def ingest_comments(subreddit, database): for comment in subreddit.sub_object.comments(limit=None): if database.session.query(Comment).filter_by( comment_id=comment.id).count() > 0: break db_submission = database.session.query(Submission).filter_by( submission_id=comment.link_id[3:]).first() if db_submission is None: db_submission = add_submission(subreddit, database, None, comment.submission) db_user = database.session.query(User).filter_by( name=comment.author.name).first() if db_user is None: db_user = User(name=comment.author.name) database.session.add(db_user) db_comment = database.session.merge( Comment(comment_id=comment.id, author=db_user, submission=db_submission, created=datetime.utcfromtimestamp(comment.created_utc))) if db_submission.is_restricted and comment.author.name != "CustomModBot": author_result = author_restricted(subreddit, database, db_user) if author_result is not None: counters.user_comments.labels(subreddit=subreddit.name, result="filtered").inc() comment.mod.remove(mod_note=f"filtered: {author_result}") db_comment.is_removed = True log.info( f"Comment {comment.id} by u/{comment.author.name} removed: {author_result}" ) else: counters.user_comments.labels(subreddit=subreddit.name, result="allowed").inc() else: counters.user_comments.labels(subreddit=subreddit.name, result="allowed").inc()
def ingest_comments(subreddit, database): for comment in subreddit.sub_object.comments(limit=None): if database.session.query(Comment).filter_by(comment_id=comment.id).count() > 0: break db_submission = database.session.query(Submission).filter_by(submission_id=comment.link_id[3:]).first() if db_submission is None: db_submission = add_submission(subreddit, database, None, comment.submission) db_user = database.session.query(User).filter_by(name=comment.author.name).first() if db_user is None: db_user = User(name=comment.author.name) database.session.add(db_user) db_comment = database.session.merge(Comment( comment_id=comment.id, author=db_user, submission=db_submission, created=datetime.utcfromtimestamp(comment.created_utc), subreddit_id=subreddit.sub_id )) if db_submission.is_restricted and comment.author.name != "CustomModBot": author_result = author_restricted(subreddit, database, db_user) if author_result is not None: counters.user_comments.labels(subreddit=subreddit.name, result="filtered").inc() action_comment(subreddit, db_comment, author_result) else: counters.user_comments.labels(subreddit=subreddit.name, result="allowed").inc() else: counters.user_comments.labels(subreddit=subreddit.name, result="allowed").inc() if not db_submission.is_notified: age_in_hours = int((datetime.utcnow() - db_submission.created).total_seconds()) / (60 * 60) if age_in_hours < 2 and database.session.query(Comment).filter(Comment.submission == db_submission).count() > 50: good_comments, bad_comments = get_comments_for_thread(subreddit, database, db_submission.submission_id) notify_string = f"Non-moderated submission is {round(age_in_hours, 1)} hours old with {len(good_comments)} comments from good accounts and {len(bad_comments)} comments from accounts with low history: <https://www.reddit.com/r/{subreddit.name}/comments/{db_submission.submission_id}/>" log.info(notify_string) #requests.post(subreddit.webhook, data={"content": notify_string}) db_submission.is_notified = True
def requesthandler(self): """Combined GET and POST processor""" md5hash = self.request.get('md5hash') guid = self.request.get('guid') username = self.request.get('username') tl = self.request.get('tl') cl = self.request.get('cl') city = self.request.get('city') country = self.request.get('country') output = self.request.get('output') doc = self.request.get('doc') if len(md5hash) > 0 or len(guid) > 0 or len(username) > 0 or len(tl) > 0 or len(cl) > 0 or len(city) > 0 or len(country) > 0: validquery = True else: validquery = False if validquery: self.response.headers['Accept-Charset']='utf-8' text = Comment.get(md5hash=md5hash,guid=guid,username=username, tl=tl, cl=cl, city=city, country=country, output=output) if output == 'xml' or output =='rss': self.response.headers['Content-Type']='text/xml' elif output ==' json': self.response.headers['Content-Type']='text/plain' else: self.response.headers['Content-Type']='text/html' self.response.out.write(text) else: t = '<table><form action=/comments/get method=get accept-charset=utf-8>' t = t + '<tr><td>MD5Hash of Source Text</td><td><input type=text name=md5hash></td></tr>' t = t + '<tr><td>GUID of Translation to Request Comments For</td><td><input type=text name=guid></td></tr>' t = t + '<tr><td>Comments By Username</td><td><input type=text name=username></td></tr>' t = t + '<tr><td>Translation Language</td><td><input type=text name=tl></td></tr>' t = t + '<tr><td>Language Comments Are In</td><td><input type=text name=cl></td></tr>' t = t + '<tr><td>City</td><td><input type=text name=city></td></tr>' t = t + '<tr><td>Country</td><td><input type=text name=country></td></tr>' t = t + '<tr><td>Output Format</td><td><input type=text name=output value=xml></td></tr>' t = t + '<tr><td colspan=2><input type=submit value=SEARCH></td></tr>' t = t + '</table></form>' www.serve(self, t, sidebar = self.__doc__, title = '/comments/get')
def put(self, post_id): data = json.loads(self.request.body) comment = Comment.get_by_id(int(data["id"])) blog = Blog.get_by_id(int(post_id)) cookie_val = self.request.cookies.get("user_id") new_title = data["title"] new_content = data["content"] if not (new_content and new_title): message = "Invalid. Both title and comment must not be empty." self.send_response(400, message) return if not self.blog_exists(blog): self.send_response(404) return if not self.comment_exists(comment): message = "Invalid. The comment does not exist." self.send_response(400, message) return if not self.is_signed_in(cookie_val): message = "Invalid. Must be signed in to edit comments." self.send_response(400, message) return if not self.is_author(cookie_val, comment): message = "Invalid. Only its author is allowed to edit." self.send_response(400, message) return comment.title = new_title comment.content = new_content comment.put() message = json.dumps( {"success": "The comment has been updated successfully."}) self.send_response(200, message) self.response.set_status(200)
def requesthandler(self): guid = self.request.get('guid') cl = self.request.get('cl') comment = clean(self.request.get('comment')) if len(cl) < 1 and len(comment) > 4: cl = TestLanguage.language(text=comment) remote_addr = self.request.remote_addr ip = self.request.get('ip') if len(ip) > 0: remote_addr = ip username = self.request.get('username') pw = self.request.get('pw') session='' location = geo.get(remote_addr) if type(location) is dict: try: city = location['city'] state= location['state'] country= location['country'] except: city = '' state = '' country = '' try: latitude=location['latitude'] longitude=location['longitude'] except: latitude = None longitude = None if len(comment) > 5 and len(guid) > 7: emptyform=False else: emptyform=True if not emptyform: spamchecked = False akismetkey = Settings.get('akismet') root_url = Settings.get('root_url') if len(root_url) > 0 and string.count(root_url, 'http://') < 1: root_url = 'http://' + root_url a = Akismet() a.setAPIKey(akismetkey, blog_url = root_url) if a.verify_key(): data = dict() data['user_ip']=remote_addr data['user_agent']=self.request.headers['User-Agent'] if a.comment_check(comment, data): spam=True else: spam=False spamchecked=True else: spam=False spamchecked=False result = False if len(username) > 0: session = Users.auth(username=username, pw=pw, session='') if len(session) < 8: username='' if not spam: tdb = db.Query(Translation) tdb.filter('guid = ', guid) item = tdb.get() if item is not None: md5hash = item.md5hash sl = item.sl tl = item.tl st = item.st tt = item.tt domain = item.domain url = item.url professional = item.professional author = item.username cdb = db.Query(Comment) cdb.filter('guid = ', guid) cdb.filter('remote_addr = ', remote_addr) item = cdb.get() if item is None: item = Comment() item.guid = guid item.md5hash = md5hash item.tl = tl item.cl = cl item.comment = comment item.username = username item.spamchecked = spamchecked item.spam = spam item.remote_addr = remote_addr timestamp = datetime.datetime.now() item.minute = timestamp.minute item.hour = timestamp.hour item.day = timestamp.day item.month = timestamp.month item.year = timestamp.year item.domain = domain item.url = url item.city = city item.state = state item.country = country try: item.latitude = latitude item.longitude = longitude except: pass item.put() if professional and len(author) > 0: LSP.comment(guid, comment, lsp=author, username=username, remote_addr=remote_addr) result = True self.response.headers['Content-Type']='text/plain' if result: self.response.out.write('ok') else: self.error(500) self.response.out.write('error') else: tdb = db.Query(Translation) tdb.order('-date') item = tdb.get() if item is not None: guid = item.guid else: guid = '' t = '<table><form action=/comments/submit method=post accept-charset=utf-8>' t = t + '<tr><td>GUID of Translation (guid)</td><td><input type=text name=guid value="' + guid + '"></td></tr>' t = t + '<tr><td>Comment (comment)</td<td><input type=text name=comment></td></tr>' t = t + '<tr><td>Username (username, optional)</td><td><input type=text name=username></td></tr>' t = t + '<tr><td>Password (pw, optional)</td><td><input type=text name=pw></td></tr>' t = t + '<tr><td colspan=2><input type=submit value=SUBMIT></td></tr></table></form>' www.serve(self,t,sidebar=self.__doc__, title = '/comments/submit')
def get(self, bookId): args = commentsV.parse_args() args['bookId'] = bookId print(args) result = Comment.getBookComments(args) return result['data'], result['code']
database.session.commit() database.engine.dispose() sys.exit() db_submission = database.session.query(Submission).filter_by(submission_id=submission_id).first() if db_submission is None: db_submission = Submission( submission_id=submission_id, created=comment_created, is_restricted=False ) database.session.add(db_submission) db_user = database.session.query(User).filter_by(name=comment['author']).first() if db_user is None: db_user = database.session.merge(User(name=comment['author'])) db_comment = database.session.merge(Comment( comment_id=comment['id'], author=db_user, submission=db_submission, created=comment_created, subreddit_id=3 )) if count % 1000 == 0: log.info(f"{count} : {(comment_created.strftime('%Y-%m-%d'))}") database.session.commit() database.engine.dispose()
def get(self): args = listV.parse_args() result = Comment.getAll(args) return result['data'], result['code']
def delete(self, commentId): result = Comment.delete(commentId) return result['data'], result['code']
def patch(self, commentId): result = Comment.approve(commentId) return result['data'], result['code']
def before_request(): g.db = connect_db(app.config['DB']) User.set_db(g.db) Task.set_db(g.db) Comment.set_db(g.db) Project.set_db(g.db)
if db_submission is None: db_submission = Submission(submission_id=submission_id, created=comment_created, is_restricted=False) database.session.add(db_submission) db_user = database.session.query(User).filter_by( name=comment['author']).first() if db_user is None: db_user = database.session.merge(User(name=comment['author'])) if database.session.query(Comment).filter_by( comment_id=comment['id']).first() is not None: log.info(f"{count} : {(comment_created.strftime('%Y-%m-%d'))}") log.info(f"Found existing comment, exiting") database.session.commit() database.engine.dispose() sys.exit() db_comment = database.session.merge( Comment(comment_id=comment['id'], author=db_user, submission=db_submission, created=comment_created)) if count % 1000 == 0: log.info(f"{count} : {(comment_created.strftime('%Y-%m-%d'))}") database.session.commit() database.engine.dispose()
def get(self): args = bookCommentV.parse_args() args['userId'] = request.environ['decoded']['id'] result = Comment.getUserComment(args) return result['data'], result['code']
def patch(self): args = saveCommentV.parse_args() args['userId'] = request.environ['decoded']['id'] result = Comment.updateByUser(args) return result['data'], result['code']
def post(self): args = saveCommentV.parse_args() args['userId'] = request.environ['decoded']['id'] result = Comment.create(args) return result['data'], result['code']
db_submission = Submission(submission_id=comment.submission_id, created=comment.created, is_restricted=False) database_prod.session.add(db_submission) comment_author_name = comment.author.name db_user = database_prod.session.query(User).filter_by( name=comment_author_name).first() if db_user is None: new_users += 1 db_user = database_prod.session.merge( User(name=comment_author_name)) database_prod.session.merge( Comment(comment_id=comment.comment_id, author=db_user, submission=db_submission, created=comment.created, subreddit_id=3, karma=comment.karma, is_removed=comment.is_removed, is_deleted=comment.is_deleted)) count += 1 if count % 1000 == 0: log.info( f"{count}/{total_comments}: {new_submissions}|{new_users}") database_prod.session.commit() log.info(f"{count}/{total_comments}: {new_submissions}|{new_users}") database_prod.close() database_new.close()
def post(self, post_id): post_button = self.request.get("postbutton").split(',') key = db.Key.from_path('Post', int(post_id), parent=blog_key()) post = db.get(key) user_key = self.user.key() # When the user clicks 'like' if post_button[0] == "like": # If the user already liked the post, decrease likes_total (unlike # post) if self.user.key().id() != post.postuser.key().id(): if user_key in post.likedby: post.likedby.remove(user_key) post.likes_total -= 1 post.put() else: # Increase the likes_total, and append the user to 'likedby' # list post.likes_total += 1 post.likedby.append(user_key) post.put() self.redirect('/blog/%s' % str(post.key().id())) return elif post_button[0] == "delete": if self.user.key().id() != post.postuser.key().id(): post.delete() self.redirect('/') return else: self.redirect('/login') return # Add new comment to the post elif post_button[0] == "comment": if self.user: comment_text = self.request.get("comment_text") commentuser = self.user newcomment = Comment(parent=post, commentuser=commentuser, commenttext=comment_text) newcomment.put() self.redirect('/blog/%s' % str(post.key().id())) return else: self.redirect('/login') return # Edit existing post comment elif post_button[0] == "editcomment": key = db.Key.from_path('Comment', int(post_button[1]), parent=post.key()) c = db.get(key) # If the logged in user is also the comment author, open the # comment in edit mode if c.commentuser.key().id() == self.user.key().id(): c.editmode = True c.put() self.redirect('/blog/%s' % str(post.key().id())) return # Delete existing comment elif post_button[0] == "deletecomment": key = db.Key.from_path('Comment', int(post_button[1]), parent=post.key()) c = db.get(key) if c and self.user.key().id() == c.commentuser.key().id(): c.delete() self.redirect('/blog/%s' % str(post.key().id())) return else: self.redirect('/login') return # Submit the edited comment to the db elif post_button[0] == "submitcommentedit": key = db.Key.from_path('Comment', int(post_button[1]), parent=post.key()) c = db.get(key) if c and self.user.key().id() == c.commentuser.key().id(): c.commenttext = self.request.get("comment_edit_text") c.editmode = False c.put() self.redirect('/blog/%s' % str(post.key().id())) return else: comments = db.GqlQuery( "SELECT * FROM Comment WHERE ANCESTOR IS :1 ", post) for c in comments: c.editmode = True c.put() self.redirect('/blog/%s' % str(post.key().id()))