How to set the creation date
This How-to applies to:
Plone 2.1.x, Plone 2.0.x
This How-to is intended for:
Developers
Im ZMI add a Script (Python) to your Plone's root, name it setdate and fill it with the following code:
# set creationDate and effectiveDate to a given date.
# by jensens
date="-".join(traverse_subpath)
try:
d= DateTime(date)
except:
return "problem with subpath '%s'. usage: setdate/YYYY/MM/DD" % date
context.setModificationDate(date)
context.setCreationDate(date)
context.setEffectiveDate(date)
context.reindexObject()
return "date on '%s' successfully set to %s." % (context.title_or_id(), date)
Navigate to the object you want to change and append to its URL setdate/2005/09/17.
Example:
http://www.linux.org/Members/torvalds/news_linuxstarted/setdate/1991/08/25
It works not for Plone 2.1.1 (for some reason there is setModificationDate and setCreationDate not available in restricted code. This will be fixed in upcoming Archetypes releases (just replace ExtensibleMetadata.py by the one from Archetypes SVN release-1_3-branch). Here both methods are protected by Manage Portal.
Thats it.
Steps for Plone 3
item.setEffectiveDate(date)
item.setModificationDate(date)
item.indexObject() # NOT redindexObject()
Modification date
To be able to succesfuly save a different modification date I had to change the order of the date setting calls to:
context.setCreationDate(date) context.setEffectiveDate(date) context.reindexObject() context.setModificationDate(date)
(On Plone 2.5 if it matters).