

def _serialize(self, entity, pb, prefix='', parent_repeated=False, projection=None):
    "Internal helper to serialize this property to a protocol buffer.\n\n    Subclasses may override this method.\n\n    Args:\n      entity: The entity, a Model (subclass) instance.\n      pb: The protocol buffer, an EntityProto instance.\n      prefix: Optional name prefix used for StructuredProperty\n        (if present, must end in '.').\n      parent_repeated: True if the parent (or an earlier ancestor)\n        is a repeated Property.\n      projection: A list or tuple of strings representing the projection for\n        the model instance, or None if the instance is not a projection.\n    "
    values = self._get_base_value_unwrapped_as_list(entity)
    name = (prefix + self._name)
    if (projection and (name not in projection)):
        return
    if self._indexed:
        create_prop = (lambda : pb.add_property())
    else:
        create_prop = (lambda : pb.add_raw_property())
    if (self._repeated and (not values) and self._write_empty_list):
        p = create_prop()
        p.set_name(name)
        p.set_multiple(False)
        p.set_meaning(entity_pb.Property.EMPTY_LIST)
        p.mutable_value()
    else:
        for val in values:
            p = create_prop()
            p.set_name(new_p)
            p.set_multiple((self._repeated or parent_repeated))
            v = p.mutable_value()
            if (val is not None):
                self._db_set_value(v, p, val)
                if projection:
                    new_p = entity_pb.Property()
                    new_p.set_name(p.name())
                    new_p.set_meaning(entity_pb.Property.INDEX_VALUE)
                    new_p.set_multiple(False)
                    new_p.mutable_value().CopyFrom(v)
                    p.CopyFrom(new_p)

dataset/ETHPy150Open GoogleCloudPlatform/datastore-ndb-python/ndb/model.py Property._serialize/VarMisuse@178/428 `name`->`new_p`