

def _has_value(self, entity, rest=None):
    ok = super(StructuredProperty, self)._has_value(entity)
    if (ok and rest):
        lst = self._get_base_value_unwrapped_as_list(entity)
        if (len(lst) != 1):
            raise RuntimeError(('Failed to retrieve sub-entity of StructuredProperty %s' % self._name))
        subent = lst[0]
        if (subent is None):
            return True
        subprop = subent._properties.get(rest[0])
        if (subprop is None):
            ok = False
        else:
            ok = subprop._has_value(subent, rest[1:])
    return ok

dataset/ETHPy150Open GoogleCloudPlatform/datastore-ndb-python/ndb/model.py StructuredProperty._has_value/original