예제 #1
0
 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)
예제 #2
0
    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)
예제 #3
0
 def __delete__(self, instance):
     raise TraitAttributeError("can't be deleted", attr=self)
예제 #4
0
 def __delattr__(self, item):
     raise TraitAttributeError("Deleting an Attr field is not supported.")