This is a guide to show how to restore a deleted object in ERP5.
Table of Contents
ZODB Object System¶
The ZODB contains every operation done since the begining (or the latest pack). It means that every objects and all their modifications stay forever in the ZODB database.
Restoring a Deleted Object from ZODB¶
For instance, right after an upgrade, one of you module was replaced to a new one with the same ID. All your document in this module are gone and you need to retreive them back.
The goal is to use the ZODB api to get the OID of the previous module and then apply it as current OID.
We can do it thanks to an external method, but I suggest to use pdb instead, as it is more easy to get an output and to react according to them :
(Pdb) x = self._p_jar.db() # self is the portal
Output the list of latest 123 entries of the history and locate the transaction that replaced the module by ID (TID)
(Pdb) pp x.history(self._p_oid, 123)
[..]
(Pdb) tid = x.history(self._p_oid, 123)[X]["tid"] # where X is the number you just located
Get the old module OID from its TID
(Pdb) z = x.open(before=tid)
(Pdb) oid = z.get(self._p_oid).my_module._p_oid
(Pdb) z.close()
Get the old module from its OID
(Pdb) y = self._p_jar.get(oid)
Replace new module by old module and done
(Pdb) self._delOb('my_module')
(Pdb) self._setOb('my_module', y)
(Pdb) c
Now, you may want to reindex your entire module by going to your browser URL bar and typing <URL>/my_module/Folder_reindexAll
.