

def _deserialize(self, entity, p, unused_depth=1):
    'Internal helper to deserialize this property from a protocol buffer.\n\n    Subclasses may override this method.\n\n    Args:\n      entity: The entity, a Model (subclass) instance.\n      p: A Property Message object (a protocol buffer).\n      depth: Optional nesting depth, default 1 (unused here, but used\n        by some subclasses that override this method).\n    '
    if (p.meaning() == entity_pb.Property.EMPTY_LIST):
        self._store_value(entity, [])
        return
    val = self._db_get_value(p.value(), p)
    if (val is not None):
        val = _BaseValue(val)
    if self._repeated:
        if self._has_value(entity):
            value = self._retrieve_value(entity)
            assert isinstance(value, list), repr(value)
            value.append(val)
        else:
            value = [val]
    else:
        value = val
    self._store_value(entity, value)

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