问题
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:
- Go to portal_purgepolicy and set the number to some number (I usually use '3' to keep at least some history).
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:
- manage page
- "Control Panel"
- "database"
- "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