PyCON 2024 in Pittsburgh experience
I am a regular visitior of PyCON US conference since 2001 and I visited most
Deleted some Plone folder lately? Undo not working? Continue with reading...
It is well-known that the Undo functionality of Zope (as as wrapped through Plone UI) usually does not work when other transactions happened in-between. Common use-case: you deleted some content (e.g. a Plone folder or a Plone document) some days ago and you need it back (it's usually the boss messing up company contents and then yelling days later at you to get the content back).
You friendly helper is dm.historical (one of the few Dieter tools I really appreciate).
Here is the blueprint how to recover removed content from a ZODB storage. We assume that we are running some Plone site and want to recover a folder originally located under /plone/myfolder and now it is gone and you want it back.
from DateTime import DateTime from dm.historical import getObjectAt site = getObjectAt(app.plone, DateTime('2010-08-05 14:00:00')) folder = site['myfolder'] folder.manage_exportObject()
Keep in mind that you can not restore object versions older than the timestamp of your last ZODB pack operation. So when you packed one week ago (with the option keeping the revisions of the last seven days) you will not be able to restore revisions older than two weeks.