<commit_before>from rest_framework.permissions import BasePermission


class ObjectHasTokenUser(BasePermission):
    """
    The object's user matches the token's user.
    """
    def has_object_permission(self, request, view, obj):
        token = request.auth

        if not token:
            return False

        if not hasattr(token, 'scope'):
            assert False, ('TokenHasReadWriteScope requires the'
                           '`OAuth2Authentication` authentication '
                           'class to be used.')

        if hasattr(obj, 'user'):
            print 'token.user', token.user
            print 'obj.user', obj.user

            return token.user == obj.user
<commit_msg>Remove debugging code, fix typo<commit_after>from rest_framework.permissions import BasePermission


class ObjectHasTokenUser(BasePermission):
    """
    The object's user matches the token's user.
    """
    def has_object_permission(self, request, view, obj):
        token = request.auth

        if not token:
            return False

        if not hasattr(token, 'scope'):
            assert False, ('ObjectHasTokenUser requires the'
                           '`OAuth2Authentication` authentication '
                           'class to be used.')

        if hasattr(obj, 'user'):
            return token.user == obj.user

{'fraction_non_alphanumeric': 0.08737864077669903, 'fraction_numerical': 0.0014936519790888724, 'mean_word_length': 2.0454545454545454, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5409139', 'n_tokens_mistral': 344, 'n_tokens_neox': 329, 'n_words': 102}