Purging all old CMFEditions versions

前端 未结 4 1269
北恋
北恋 2020-12-30 11:37

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

4条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-30 11:58

    1. Go to portal_purgepolicy and set the number to some number (I usually use '3' to keep at least some history).
    2. 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()
      

提交回复
热议问题