How to rollback changes of property values in an ontology?

Posted by blmoistawinde on
URL: http://owlready.306.s1.nabble.com/How-to-rollback-changes-of-property-values-in-an-ontology-tp810.html

Hello,
I want to rollback some changes of property values at runtime, like:

onto = get_ontology("pizza.owl").load()
test_pizza = onto.Pizza("test_pizza_owl_identifier")
test_pizza.has_topping = []
commit()
test_pizza.has_topping = [ onto.CheeseTopping(), onto.TomatoTopping() ]
rollback()
print(test_pizza.has_topping)    # again is []

I've tried 2 ways for the pseudo `commit()` and `rollback()`, but they all failed.

1. backup file
onto.save("backup1.owl")
test_pizza.has_topping = [ onto.CheeseTopping(), onto.TomatoTopping() ]
onto = get_ontology("backup1.owl").load(reload=True)
test_pizza = onto.search_one(type=onto.Pizza)
test_pizza.has_topping # [pizza.cheesetopping2, pizza.tomatotopping2]

2. database commit
onto.world.graph.db.commit()
# changes here
onto.world.graph.db.rollback()
# same as 1.

Are there any existing solutions for this? Thanks a lot!

Best regards,
blmoistawinde