Re: Do MappingStorage is able to solve conflicts
Jason Madden <[email protected]> Fri, 12 Oct 2018 10:03:06 -0500
| Newsgroups | gmane.comp.web.zope.zodb |
|---|---|
| Message-ID | <[email protected]> |
MappingStorage does not extend ConflictResolvingStorage and I wouldn't expect it to resolve conflicts. If you want an in-memory storage that does resolve conflicts, try DemoStorage (if not given a base or changes storage, it uses MappingStorage objects). > On Oct 12, 2018, at 05:02, Éloi Rivard <[email protected]> wrote: > > Hi. I have a very simple piece of code with a different behavior depending on it is running on a MappingStorage or a ClientStorage. Conflicts do not seem to be solved when I use a MappingStorage. > > import ZODB, transaction, persistent > from ZEO.ClientStorage import ClientStorage > > class MyMapping(persistent.mapping.PersistentMapping): > def _p_resolveConflict(self, old, saved, new): > return {"conflict": "happened"} > > > db = ZODB.DB(None) > #db = ZODB.DB(ClientStorage(("localhost", 9999))) > with db.transaction() as conn: > conn.root.x = MyMapping() > > my_transaction_manager = transaction.TransactionManager() > conn1 = db.open(my_transaction_manager) > my_transaction_manager.commit() > > with db.transaction() as conn2: > conn2.root.x["a"] = 1 > > conn1.root.x["b"] = 2 > my_transaction_manager.commit() > > This piece of code is stupid, but just shows that a conflict is raised with a MappingStorage, and not with a ClientStorage. > > Éloi > > -- > You received this message because you are subscribed to the Google Groups "zodb" group. > To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "zodb" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.