def has_object_permission(self, request, view, obj):
        """
        Overrides the standard function and figures out methods to call for object permissions.
        """
        if not self.object_permissions:
            return True

        serializer_class = view.get_serializer_class()
        model_class = serializer_class.Meta.model
        action_method_name = None
        if hasattr(view, 'action'):
            action = self._get_action(view.action)
            action_method_name = "has_object_{action}_permission".format(action=action)
            # If the specific action permission exists then use it, otherwise use general.
            if hasattr(obj, action_method_name):
                return getattr(obj, action_method_name)(request)

        if request.method in permissions.SAFE_METHODS:
            assert hasattr(obj, 'has_object_read_permission'), \
                self._get_error_message(model_class, 'has_object_read_permission', action_method_name)
            return obj.has_object_read_permission(request)
        else:
            assert hasattr(obj, 'has_object_write_permission'), \
                self._get_error_message(model_class, 'has_object_write_permission', action_method_name)
            return obj.has_object_write_permission(request)
dataset/ETHPy150Open dbkaplan/dry-rest-permissions/dry_rest_permissions/generics.py/DRYPermissions.has_object_permission/original