Created
March 8, 2017 07:50
-
-
Save zupo/da307cc7783067cd64c2a3cdd7d33fa4 to your computer and use it in GitHub Desktop.
Migrate modified timestamps between Plone instances
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run the following inside bin/instance debug to get list of paths + dates | |
# print ''.join(['{}|{}\n'.format(b.getURL(), b.modified) | |
# for b in app.office.portal_catalog.unrestrictedSearchResults()]) | |
# Put the list in the MODIFIEDS variable below. Then run the script inside | |
# bin/instance debug on new server | |
MODIFIEDS = [ | |
'events', | |
'news', | |
'foo/bar', | |
... | |
] | |
from DateTime import DateTime | |
portal = app.Plone | |
for line in MODIFIEDS: | |
try: | |
path, timestamp = line.split('|') | |
obj = portal.unrestrictedTraverse(path) | |
obj.setModificationDate(DateTime(timestamp)) | |
obj.reindexObject(idxs=['modified']) | |
except: | |
import pdb; pdb.set_trace() | |
import transaction | |
transaction.commit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment