Purging all old CMFEditions versions

≡放荡痞女 提交于 2019-11-29 09:12:49

问题


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


回答1:


  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()
    



回答2:


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




回答3:


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.




回答4:


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!



来源:https://stackoverflow.com/questions/9683466/purging-all-old-cmfeditions-versions

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!