def comments():
 try:
  task_id = request.args[0]
 except:
  raise HTTP(400)
 table = s3db.project_comment
 field = table.task_id
 field.default = task_id
 field.writable = field.readable = False
 r = s3_request(prefix='project', name='comment', args=[], vars=None, extension='html')
 r.customise_resource()
 form = s3base.S3SQLCustomForm('parent', 'task_id', 'body')(r)
 comments = db((field == task_id)).select(table.id, table.parent, table.body, table.created_by, table.created_on)
 output = UL(_id='comments')
 for comment in comments:
  if (not comment.parent):
   thread = comment_parse(comment, comments, task_id=task_id)
   output.append(thread)
 script = ''.join("$('#comments').collapsible({xoffset:'-5',yoffset:'50',imagehide:img_path+'arrow-down.png',imageshow:img_path+'arrow-right.png',defaulthide:false})\n$('#project_comment_parent__row1').hide()\n$('#project_comment_parent__row').hide()\n$('#project_comment_body').ckeditor(ck_config)\n$('#submit_record__row input').click(function(){\n $('#comment-form').hide()\n $('#project_comment_body').ckeditorGet().destroy()\n return true\n})")
 output = DIV(output, DIV(H4(T('New Post'), _id='comment-title'), form, _id='comment-form', _class='clear'), SCRIPT(script))
 return XML(output)

def comments ( ) : try : task_id = request . args [ 0 ] except : raise HTTP ( 400 ) table = s3db . project_comment field = table . task_id field . default = task_id field . writable = field . readable = False r = s3_request ( prefix = 'project' , name = 'comment' , args = [ ] , vars = None , extension = 'html' ) r . customise_resource ( ) form = s3base . S3SQLCustomForm ( 'parent' , 'task_id' , 'body' ) ( r ) comments = db ( ( field == task_id ) ) . select ( table . id , table . parent , table . body , table . created_by , table . created_on ) output = UL ( _id = 'comments' ) for comment in comments : if ( not comment . parent ) : thread = comment_parse ( comment , comments , task_id = task_id ) output . append ( thread ) script = '' . join ( "$('#comments').collapsible({xoffset:'-5',yoffset:'50',imagehide:img_path+'arrow-down.png',imageshow:img_path+'arrow-right.png',defaulthide:false})\n$('#project_comment_parent__row1').hide()\n$('#project_comment_parent__row').hide()\n$('#project_comment_body').ckeditor(ck_config)\n$('#submit_record__row input').click(function(){\n $('#comment-form').hide()\n $('#project_comment_body').ckeditorGet().destroy()\n return true\n})" ) output = DIV ( output , DIV ( H4 ( T ( 'New Post' ) , _id = 'comment-title' ) , form , _id = 'comment-form' , _class = 'clear' ) , SCRIPT ( script ) ) return XML ( output )
receive use request to view comments .