def comment_parse(comment, comments, solution_id=None):
    '\n        Parse a Comment\n\n        @param: comment - a gluon.sql.Row: the current comment\n        @param: comments - a gluon.sql.Rows: full list of comments\n        @param: solution_id - a reference ID: optional solution commented on\n    '
    author = B(T('Anonymous'))
    if comment.created_by:
        utable = s3db.auth_user
        ptable = s3db.pr_person
        ltable = s3db.pr_person_user
        query = (utable.id == comment.created_by)
        left = [ltable.on((ltable.user_id == utable.id)), ptable.on((ptable.pe_id == ltable.pe_id))]
        row = db(query).select(utable.email, ptable.first_name, ptable.middle_name, ptable.last_name, left=left, limitby=(0, 1)).first()
        if row:
            person = row.pr_person
            user = row[utable._tablename]
            username = s3_fullname(person)
            email = user.email.strip().lower()
            import hashlib
            hash = hashlib.md5(email).hexdigest()
            url = ('http://www.gravatar.com/%s' % hash)
            author = B(A(username, _href=url, _target='top'))
    if ((not solution_id) and comment.solution_id):
        solution = ('re: %s' % s3db.delphi_solution_represent(comment.solution_id))
        header = DIV(author, ' ', solution)
        solution_id = comment.solution_id
    else:
        header = author
    thread = LI(DIV(s3base.s3_avatar_represent(comment.created_by), DIV(DIV(header, _class='comment-header'), DIV(XML(comment.body)), _class='comment-text'), DIV(DIV(comment.created_on, _class='comment-date'), DIV(A(T('Reply'), _class='action-btn'), _onclick=('comment_reply(%i);' % comment.id), _class='comment-reply'), _class='fright'), _id=('comment-%i' % comment.id), _solution_id=solution_id, _class='comment-box'))
    children = UL(_class='children')
    id = comment.id
    count = 0
    for comment in comments:
        if (comment.parent == id):
            count = 1
            child = comment_parse(comment, comments, solution_id=solution_id)
            children.append(child)
    if (count == 1):
        thread.append(children)
    return thread
Parse a Comment

@param: comment - a gluon.sql.Row: the current comment
@param: comments - a gluon.sql.Rows: full list of comments
@param: solution_id - a reference ID: optional solution commented on
def comment_parse(comment, comments, solution_id=None):
    '\n        Parse a Comment\n\n        @param: comment - a gluon.sql.Row: the current comment\n        @param: comments - a gluon.sql.Rows: full list of comments\n        @param: solution_id - a reference ID: optional solution commented on\n    '
    author = B(T('Anonymous'))
    if comment.created_by:
        utable = s3db.auth_user
        ptable = s3db.pr_person
        ltable = s3db.pr_person_user
        query = (utable.id == comment.created_by)
        left = [ltable.on((ltable.user_id == utable.id)), ptable.on((ptable.pe_id == ltable.pe_id))]
        row = db(query).select(utable.email, ptable.first_name, ptable.middle_name, ptable.last_name, left=left, limitby=(0, 1)).first()
        if row:
            person = row.pr_person
            user = row[utable._tablename]
            username = s3_fullname(person)
            email = user.email.strip().lower()
            import hashlib
            hash = hashlib.md5(email).hexdigest()
            url = ('http://www.gravatar.com/%s' % hash)
            author = B(A(username, _href=url, _target='top'))
    if ((not solution_id) and comment.solution_id):
        solution = ('re: %s' % s3db.delphi_solution_represent(comment.solution_id))
        header = DIV(author, ' ', solution)
        solution_id = comment.solution_id
    else:
        header = author
    thread = LI(DIV(s3base.s3_avatar_represent(comment.created_by), DIV(DIV(header, _class='comment-header'), DIV(XML(comment.body)), _class='comment-text'), DIV(DIV(comment.created_on, _class='comment-date'), DIV(A(T('Reply'), _class='action-btn'), _onclick=('comment_reply(%i);' % comment.id), _class='comment-reply'), _class='fright'), _id=('comment-%i' % comment.id), _solution_id=solution_id, _class='comment-box'))
    children = UL(_class='children')
    id = comment.id
    count = 0
    for comment in comments:
        if (comment.parent == id):
            count = 1
            child = comment_parse(comment, comments, solution_id=solution_id)
            children.append(child)
    if (count == 1):
        thread.append(children)
    return thread