We have big huge site which database should be prepared for development copies.
How one can remove all old history versions of all content items? This way we could g
I found (in what was probably a case of RTFM on my case, but anyway) that opening up the Zope site (http://localhost:8080/ say) directly, and navigating as follows:
led me to a page which offered to "pack" the database and remove all history older than X days old. This worked like a treat!
Run the following script:
from DateTime import DateTime
from Products.CMFCore.utils import getToolByName
from Products.CMFEditions.utilities import dereference
policy = getToolByName(self.context, 'portal_purgepolicy')
catalog = getToolByName(self.context, 'portal_catalog')
for count, brain in enumerate(catalog()):
obj = brain.getObject()
# only purge old content
if obj.created() < (DateTime() - 30):
obj, history_id = dereference(obj)
policy.beforeSaveHook(history_id, obj)
print 'purged object ' + obj.absolute_url_path()
I've details for Plone 3 (but note that I know that this is changed a little on Plone 4).
In Plone 3.3 histories are all stored inside the portal_historiesstorage/repo object. There you have a _shadowStorage subobject.
I found that if you delete this persistent object, it's created from scratch when needed.
Hope this help in some way
Here are instructions to delete _shadowStorage, as keul hints above:
Start ZEO client in debug mode:
bin/client1 debug
Then:
del app.yoursiteid.portal_historiesstorage._shadowStorage
import transaction ; transaction.commit()
No warranty. No idea what it is deleting. Apparently you get rid of all histories.