Purging all old CMFEditions versions

前端 未结 4 1235
北恋
北恋 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:57

    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:

    1. manage page
    2. "Control Panel"
    3. "database"
    4. "Main"

    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!

    0 讨论(0)
  • 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()
      
    0 讨论(0)
  • 2020-12-30 12:01

    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

    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题