On the same way than for the constructor, you can write your own set
for
all the attributes defined in your class. It allows to do job that is not
done by xdata, to set other attributes or to do whatever you want !
In that case, the meta set
is run to check the value and to set
the attribute, then the user set
is run:
# -- # Copyright (C) CEA, EDF # Author : Erwan ADAM (CEA) # -- import unittest from xdata import * class A(XObject): __init__xattributes__ = [ XAttribute("x", xtype=XInt(min=0)), ] def setX(self, value): self.test = 1 return pass class ATestCase(unittest.TestCase): def test(self): a = A(1) self.failUnlessEqual(a.test, 1) return pass if __name__ == '__main__': unittest.main() pass