def __setattr__(self, key, value): """ After owner is set disallow any field assignment """ if getattr(self, 'owner', None) is not None: raise TraitAttributeError( "Can't change an Attr after it has been bound to a class." "Reusing Attr instances for different fields is not supported." ) super(_Attr, self).__setattr__(key, value)
def __set__(self, instance, value): if isinstance(value, str): try: value = uuid.UUID(value) except ValueError: raise TraitAttributeError("Given value cannot be used as UUID for field {}".format(self.field_name)) super(DataTypeGidAttr, self).__set__(instance, value)
def __delete__(self, instance): raise TraitAttributeError("can't be deleted", attr=self)
def __delattr__(self, item): raise TraitAttributeError("Deleting an Attr field is not supported.")