Example #1
0
        if name in ['a','b','c']:
            PropertiedClasses.PropertiedClass._basic_set (self, name, value)
        else:
            raise AttributeError, name + ' is not settable.'

PropertiedClasses.set_property (Test, 'shape', Test.getShape, Test.setShape)
assert PropertiedClasses.get_property_g(Test, 'shape').im_func is  Test.getShape.im_func
PropertiedClasses.set_property (Test, 'alwayspositive', acts=Test.validate)
PropertiedClasses.set_property (Test, 'ro', nowrite=1)
PropertiedClasses.set_property (Test, 'ro3', acts = Test.validate)
PropertiedClasses.set_property (Test, 'ro2', nowrite=1)
PropertiedClasses.set_property (Test, 'ro3', nodelete=1)
PropertiedClasses.set_property (Test, 'kenny', actd=Test.kill)
PropertiedClasses.set_property (Test, 'vs', acts=validstring)
PropertiedClasses.set_property (Test2, 'alwayspositive', acts=Test2.validate)
assert PropertiedClasses.get_property_s(Test, 'alwayspositive').im_func is \
                                 Test.validate.im_func
assert PropertiedClasses.get_property_s(Test2, 'alwayspositive').im_func is \
                                 Test2.validate.im_func

t = Test((3,2))
t.a = 1
assert t.a == 1
assert t.shape == (3,2)
t.shape = (4,4)
assert t.shape == (4,4)
t.alwayspositive = 5
assert t.alwayspositive == 5
try:
    t.alwayspositive = -1
except ValueError: