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 greatly reduce the size of data needed to transfer to developer computers.
Plone 4.0
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()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With