#!/usr/bin/env python
#
# We have some SWIG (??) problems with adding/removing observers
# For some reason the following doesn't/didn't work.
#
#
import coral

M = coral.lang.UML14.Model()

observed_object = False
observed_function = False

def obs(self, x):
    print "In function observer"
    global observed_function
    observed_function = True

class C:
    def obs(self, x):
        print "In object observer"
        global observed_object
        observed_object = True


O = C()

tm = coral.getTransactionManager()
tm.addObserver(O.obs)
tm.removeObserver(O.obs)

tm.beginModifyCmd()
try:
    M.name = "foo"
finally:
    tm.endModifyCmd()

assert observed_function == False
assert observed_object == False
