Personal tools
You are here: Home Documentation How-tos How to set the creation date
Support

Get Help

Join our chat rooms or support forums if you have more specific questions.

Plone Training
Learn how to design, build, and deploy a website in Plone through one of the numerous Plone training sessions around the world.
Find Plone training…
 
Document Actions

How to set the creation date

Warning: This item is marked as outdated.

This How-to applies to: Plone 2.1.x, Plone 2.0.x
This How-to is intended for: Developers

This page describes how to set the creation date and effective date to a given value.

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.

by Jens W. Klein last modified February 4, 2006 - 23:33 All content is copyright Plone Foundation and the individual contributors.

Modification date

Posted by Pupeno at July 30, 2006 - 20:51

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

Steps for Plone 3

Posted by Sean Fulmer at May 26, 2008 - 01:07
item.setCreationDate(date)
item.setEffectiveDate(date)
item.setModificationDate(date)
item.indexObject() # NOT redindexObject()

For any issues with the web site functionality, please file a ticket.

Please consult the policy on plone.org content if you want your content published on this site.

Servers and hosting by