Search for comment :param:`id` and return a mapping of :attr:`fields`
        and values.
557355
def get(self, id):
        
        rv = self.db.execute(
            'SELECT * FROM comments WHERE id=?', (id, )).fetchone()
        if rv:
            return dict(zip(Comments.fields, rv))

        return None
216225
def comments(self, limit=None):
        
        return self._reddit.comments(self.display_name, limit=limit)
553293
def find_comment_by_id(self, comment_id):
        
        url = 'https://openapi.youku.com/v2/comments/show.json'
        params = {
            'client_id': self.client_id,
            'comment_id': comment_id
        }
        r = requests.get(url, params=params)
        check_error(r)
        return r.json()
437719
def comment_from_tag(tag):
    
    if not tag:
        return None
    comment = Comment(name=tag.name,
                      meta={'description': tag.description},
                      annotations=tag.annotations)
    return comment
1077920
def get_comments_for_reference_on_date(self, reference_id, from_, to):
        """"""
        # Implemented from azosid template for -
        # osid.relationship.RelationshipLookupSession.get_relationships_for_source_on_date_template
        if self._can('lookup'):
            return self._provider_session.get_comments_for_reference_on_date(reference_id, from_, to)
        self._check_lookup_conditions()  # raises PermissionDenied
        query = self._query_session.get_comment_query()
        query.match_source_id(reference_id, match=True)
        query.match_date(from_, to, match=True)
        return self._try_harder(query)
207073
def comments(self, value):
        

        if value is not None:
            assert type(value) in (OrderedDict, dict), "'{0}' attribute: '{1}' type is not \
            'OrderedDict' or 'dict'!".format("comments", value)
            for key, element in value.iteritems():
                assert type(key) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format(
                    "comments", key)
                assert type(element) in (OrderedDict, dict), "'{0}' attribute: '{1}' type is not \
                'OrderedDict' or 'dict'!".format("comments", key)
        self.__comments = value
195181
def get(request, obj_id):
    
    res = Result()
    c = Comment.objects.get(pk=obj_id)
    res.append(commentToJson(c))

    return JsonResponse(res.asDict())
52631
def request_comment_show(self, request_id, id, **kwargs):
        ""
        api_path = "/api/v2/requests/{request_id}/comments/{id}.json"
        api_path = api_path.format(request_id=request_id, id=id)
        return self.call(api_path, **kwargs)
385309
def delete_comment(self, comment_id):
        """"""

        comment_obj = self.query(Comment).get(comment_id)
        if comment_obj:
            logger.debug("Deleting comment {0}".format(comment_obj.id))

        self.session.delete(comment_obj)
        self.save()

        return comment_obj
338266
def get_all_comments(self):
        
        return bind_api(
            api=self,
            path='/comments',
            payload_type='comment',
            payload_list=True,
            pagination_param=['page_number', 'page_size']
        )
490974
def get_comment(value):
    
    if value and value[0] != '(':
        raise errors.HeaderParseError(
            "expected '(' but found '{}'".format(value))
    comment = Comment()
    value = value[1:]
    while value and value[0] != ")":
        if value[0] in WSP:
            token, value = get_fws(value)
        elif value[0] == '(':
            token, value = get_comment(value)
        else:
            token, value = get_qp_ctext(value)
        comment.append(token)
    if not value:
        comment.defects.append(errors.InvalidHeaderDefect(
            "end of header inside comment"))
        return comment, value
    return comment, value[1:]
1322099
def list_comments(self, page=0):
        
        from highton.models.comment import Comment
        params = {'page': int(page) * self.COMMENT_OFFSET}

        return fields.ListField(
            name=self.ENDPOINT,
            init_class=Comment
        ).decode(
            self.element_from_string(
                self._get_request(
                    endpoint=self.ENDPOINT + '/' + str(self.id) + '/' + Comment.ENDPOINT,
                    params=params
                ).text
            )
        )
910630
def update(self, id, data):
        
        self.db.execute([
            'UPDATE comments SET',
            ','.join(key + '=' + '?' for key in data),
            'WHERE id=?;'],
            list(data.values()) + [id])

        return self.get(id)
108516
def comment(request, template="generic/comments.html", extra_context=None):
    
    response = initial_validation(request, "comment")
    if isinstance(response, HttpResponse):
        return response
    obj, post_data = response
    form_class = import_dotted_path(settings.COMMENT_FORM_CLASS)
    form = form_class(request, obj, post_data)
    if form.is_valid():
        url = obj.get_absolute_url()
        if is_spam(request, form, url):
            return redirect(url)
        comment = form.save(request)
        response = redirect(add_cache_bypass(comment.get_absolute_url()))
        # Store commenter's details in a cookie for 90 days.
        for field in ThreadedCommentForm.cookie_fields:
            cookie_name = ThreadedCommentForm.cookie_prefix + field
            cookie_value = post_data.get(field, "")
            set_cookie(response, cookie_name, cookie_value)
        return response
    elif request.is_ajax() and form.errors:
        return HttpResponse(dumps({"errors": form.errors}))
    # Show errors with stand-alone comment form.
    context = {"obj": obj, "posted_comment_form": form}
    context.update(extra_context or {})
    return TemplateResponse(request, template, context)
1311685
def find_comments_by_ids(self, comment_ids):
        
        url = 'https://openapi.youku.com/v2/comments/show_batch.json'
        params = {
            'client_id': self.client_id,
            'comment_ids': comment_ids
        }
        r = requests.get(url, params=params)
        check_error(r)
        return r.json()
37224
def comment_delete(self, comment_id):
        
        return self._get('comments/{0}.json'.format(comment_id),
                         method='DELETE', auth=True)
944256
def comment_count(object):
    
    return Comment.objects.filter(
        object_id=object.pk,
        content_type=ContentType.objects.get_for_model(object)
    ).count()