comments = None user = None try: blog = Query(Blog).equal_to("objectId", blog_id).first() if blog is None: raise Err('value:notfound', 'blog', 'blog not found.') try: comments = Query(Comments).equal_to("blog", blog).descending('createdAt').find() except LeanCloudError, e: pass except LeanCloudError, e: if e.code == 101: # 服务端对应的 Class 还没创建 blog = {} else: raise e blog.set('html_content', markdown(blog.get('content'))) if comments is None: comments = [] return comments @api def update_comment(comment_id, content=''): #if user is None: #raise Err('value:notfound', 'user', 'user not found.') content = content.strip() if not content: raise Err('value:invalid', 'content', 'content cannot be empty.') comment = Query(Comments).get(comment_id) if comment is None: raise Err('value:notfound', 'comment', 'comment not found.') comment.set('content', content)
user = None try: blog = Query(Blog).equal_to("objectId", blog_id).first() if blog is None: raise Err('value:notfound', 'blog', 'blog not found.') try: comments = Query(Comments).equal_to( "blog", blog).descending('createdAt').find() except LeanCloudError, e: pass except LeanCloudError, e: if e.code == 101: # 服务端对应的 Class 还没创建 blog = {} else: raise e blog.set('html_content', markdown(blog.get('content'))) if comments is None: comments = [] return comments @api def update_comment(comment_id, content=''): #if user is None: #raise Err('value:notfound', 'user', 'user not found.') content = content.strip() if not content: raise Err('value:invalid', 'content', 'content cannot be empty.') comment = Query(Comments).get(comment_id) if comment is None: raise Err('value:notfound', 'comment', 'comment not found.')