def _sanitize_for_create(self, data):
        retval = copy.deepcopy(data)

        # self._coerce_data(retval)

        schema = self.get_schema()

        required_fields = [x for x in schema if schema[x]['required'] is True]
        ro_fields = [x for x in schema if schema[x]['read_only'] is True]

        # this should be generalized to pks, I think?
        if 'id' in required_fields:
            required_fields.remove('id')

        if 'id' in retval:
            retval.pop('id')

        for field in required_fields:
            if not field in retval:
                raise KeyError('missing required field %s' % field)

        for field in ro_fields:
            if field in retval:
                retval.pop(field)

        for field in data:
            if not field in schema.keys():
                retval.pop(field)

        return retval
dataset/ETHPy150Open rcbops/opencenter/opencenter/db/abstraction.py/DbAbstraction._sanitize_for_create/original