

def _set_value(self, entity, value):
    'Internal helper to set a value in an entity for a Property.\n\n    This performs validation first.  For a repeated Property the value\n    should be a list.\n    '
    if entity._projection:
        raise ReadonlyPropertyError('You cannot set property values of a projection entity')
    if self._repeated:
        if (not isinstance(value, (list, tuple, set, frozenset))):
            raise datastore_errors.BadValueError(('Expected list or tuple, got %r' % (value,)))
        value = [self._do_validate(v) for v in value]
    elif (value is not None):
        value = self._do_validate(value)
    self._store_value(entity, value)

dataset/ETHPy150Open GoogleCloudPlatform/datastore-ndb-python/ndb/model.py Property._set_value/original