Esempio n. 1
0
        prune = self.prune_empty
        success = []
        for value in values:
            if prune and not value:
                continue
            child = self.member_schema()
            success.append(child.set(value))
            self.append(child)

        res = all(success)
        element_set.send(self, adapted=res)
        return res

    def _set_flat(self, pairs, sep):
        return Scalar._set_flat(self, pairs, sep)

    @property
    def value(self):
        """A read-only :attr:`separator`-joined string of child values."""
        return self.separator.join(child.u for child in self)

    @property
    def u(self):
        """A read-only :attr:`separator`-joined string of child values."""
        return self.value


for cls_name in __all__:
    autodocument_from_superclasses(globals()[cls_name])
del cls_name
Esempio n. 2
0
    def _set_u(self, ustr):
        if self.writable == 'ignore':
            return
        elif self.writable:
            self.target.u = ustr
        else:
            raise TypeError(u'Ref "%s" is not writable.' % self.name)

    u = property(_get_u, _set_u)
    del _get_u, _set_u

    def _get_value(self):
        """The native value representation of the reference target."""
        return self.target.value

    def _set_value(self, value):
        if self.writable == 'ignore':
            return
        elif self.writable:
            self.target.value = value
        else:
            raise TypeError(u'Ref "%s" is not writable.' % self.name)

    value = property(_get_value, _set_value)
    del _get_value, _set_value


for cls_name in __all__:
    autodocument_from_superclasses(globals()[cls_name])
del cls_name