#!/usr/bin/env python
import coral ; metamodel=coral.lang.UML14

s=coral.Project()

c=metamodel.Class()          # It is possible to create objects
c.name="Customer"            # and modify them out of a transaction
c.__setProject__(s)

tm = coral.getTransactionManager()
tm.beginModifyCmd() # Begin a transaction
try:
    c.name="Employee"            # Modify the model
finally:
    tm.endModifyCmd()   # Finish the transaction
assert(c.name=="Employee")   # The changes are there
tm.undo()           # Undo the last transaction
assert(c.name=="Customer")   # We get the previous name
tm.redo()           # Redo the last transaction
assert(c.name=="Employee")   # Voila!
