()
| 50 | |
| 51 | # Example |
| 52 | def main(): |
| 53 | print "Creating data1 without notification for attrs name & surname" |
| 54 | data1 = Data(excluded=['name','surname']) |
| 55 | print "Creating data2 without notification for attr age" |
| 56 | data2 = Data(excluded=['age']) |
| 57 | |
| 58 | obs1 = Observer1() |
| 59 | data1.attach(obs1) |
| 60 | data1.attach(obs1) |
| 61 | |
| 62 | obs2 = Observer2() |
| 63 | data2.attach(obs2) |
| 64 | data2.attach(obs2) |
| 65 | |
| 66 | # now try it |
| 67 | # you can set any attribute directly |
| 68 | print "Setting data1.name=Heather - Notification unnecessary" |
| 69 | data1.name = 'Heather' |
| 70 | print "Setting data1.num=333 - Notification expected" |
| 71 | data1.num = 333; |
| 72 | |
| 73 | print "Setting data2.name=Molly - Notification expected" |
| 74 | data2.name = 'Molly' |
| 75 | print "Setting data2.age=28 - Notification unnecessary" |
| 76 | data2.age = 28 |
| 77 | print "Setting data2.eyecolor=blue - Notification expected" |
| 78 | data2.eyecolor='blue'; |
| 79 | |
| 80 | if __name__ == '__main__': |
| 81 | main() |
no test coverage detected