Re: Historical Version of ZODB Objects

Christopher Lozinski <[email protected]> Wed, 24 Jan 2018 09:51:00 +0100
Newsgroups gmane.comp.web.zope.zodb
Message-ID <[email protected]>
Maybe this problem is quite easy to solve with the newer versions of the ZODB.


>  From 
> https://github.com/jimfulton/pheather/blob/master/src/pheather/__init__.py#L57 <https://github.com/jimfulton/pheather/blob/master/src/pheather/__init__.py#L57>
  def history(self, size=9):
        for h in self._p_jar.db().history(self.__data._p_oid, size):
            yield h

Here is the documentation for the inner db().history method. 
  https://github.com/zopefoundation/ZODB/blob/master/src/ZODB/interfaces.py#L629 <https://github.com/zopefoundation/ZODB/blob/master/src/ZODB/interfaces.py#L629>


The critical thing is the tid.  Transaction ID.  

Using that we can open a connection into the database at the time of that version of the object was committed. 
https://github.com/zopefoundation/ZODB/blob/master/src/ZODB/Connection.py#L101 <https://github.com/zopefoundation/ZODB/blob/master/src/ZODB/Connection.py#L101>
 Connection(db,before=tid)
And then do connection.get(oid)

Where oid is the object id. 

Let me give it a shot. 

Warm Regards
Chris

-- 
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.