slim/base/permission.py
def can_with_record(self, user, action, record: DataRecord, *, available=None):
        """
        进行基于 Record 的权限判定，返回可用列。
        :param user:
        :param action:
        :param record:
        :param available: 限定检查范围
        :return: 可用列
        """
        assert action not in (A.QUERY, A.CREATE), "meaningless action check with record: [%s]" % action

        # 先行匹配规则适用范围
        rules = []
        for rule in self.record_checks:
            if record.table == rule[0] and action in rule[1]:
                rules.append(rule)

        # 逐个过检查
        if available is None: available = self.can_with_columns(user, action, record.table, record.keys())
        else: available = list(available)
        bak = available.copy()

        for rule in rules:
            ret = rule[-1](self, user, action, record, available)
            if isinstance(ret, (tuple, set, list)):
                available = list(ret)
            elif ret == '*':
                available = list(bak)
            elif not ret:
                available = []

        return available
def can_with_record(self, user, action, record: DataRecord, *, available=None):
        """
        进行基于 Record 的权限判定，返回可用列。
        :param user:
        :param action:
        :param record:
        :param available: 限定检查范围
        :return: 可用列
        """
        assert action not in (A.QUERY, A.CREATE), "meaningless action check with record: [%s]" % action

        # 先行匹配规则适用范围
        rules = []
        for rule in self.record_checks:
            if record.table == rule[0] and action in rule[1]:
                rules.append(rule)

        # 逐个过检查
        if available is None: available = self.can_with_columns(user, action, record.table, record.keys())
        else: available = list(available)
        bak = available.copy()

        for rule in rules:
            ret = rule[-1](self, user, action, record, available)
            if isinstance(ret, (tuple, set, list)):
                available = list(ret)
            elif ret == '*':
                available = list(bak)
            elif not ret:
                available = []

        return available
进行基于 Record 的权限判定，返回可用列。
        :param user:
        :param action:
        :param record:
        :param available: 限定检查范围
        :return: 可用列