Skip to content

Instantly share code, notes, and snippets.

@zupo
Created March 8, 2017 07:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zupo/da307cc7783067cd64c2a3cdd7d33fa4 to your computer and use it in GitHub Desktop.
Save zupo/da307cc7783067cd64c2a3cdd7d33fa4 to your computer and use it in GitHub Desktop.
Migrate modified timestamps between Plone instances
# 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