Re: verify an object is latest in cache
Jason Madden <[email protected]>
| Newsgroups | gmane.comp.web.zope.zodb |
|---|---|
| Message-ID | <[email protected]> |
> But in few cases I want to make sure that the object I am going to use is latest. Even if object is coming from client cache I want to verify whether it is updated or not. Is there any ZEO/ZODB API to verify an object revision ?
Hi,
You may want to use Connection.readCurrent() (e.g., `pers_obj._p_jar.readCurrent(pers_obj)` to make sure that `pers_obj` is the latest revision). When the transaction is ready to commit, if any object that you've called `readCurrent()` on is *not* the most recent, the cache will be invalidated for that object, a ConflictError will be raised, and your transaction should be retried.
From IConnection in interfaces.py:
def readCurrent(obj):
"""Make sure an object being read is current
This is used when applications want to ensure a higher level
of consistency for some operations. This should be called when
an object is read and the information read is used to write a
separate object.
"""
Jason
--
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.