Renaming content


How to programmatically rename Plone content items


This page tells how to rename Plone content objects and change their ids.

  • This only concerns URL path ids

  • Archetypes’ Unique ID (UID) is not affected by the rename operation

  • Title can be changed using setTitle() (Archetypes) or related mutator

Renaming objects

OFS interface has facilities to rename objects


Security warning: “Copy or Move” permission is needed on the object by the logged in user.


New id must be a 8-bit string, not unicode. The system might accept values in invalid format.

Example how to rename object lc to have -old suffix:

id = lc.getId()
if not lc.cb
parent = lc.aq_parent
parent.manage_renameObject(id, id + "-old")

These checks performed before rename by the manage_renameObject():

if not lc.cb_userHasCopyOrMovePermission():
    print "Does not have needed permission"

if not lc.cb_isMoveable():
    # This makes sanity checks whether the object is
    # properly connected to the database
    print "Object problem"


Testing warning: Rename mechanism relies of Persistent attribute called _p_jar to be present on the content object. By default, this is not the case on unit tests. You need to call transaction.savepoint() to make _p_jar appear on persistent objects.

If you don’t do this, you’ll receive a “CopyError” when calling manage_renameObjects that the operation is not supported.

Unit testing example:

import transaction

self.portal.invokeFactory("Document", doc")
doc = self.portal.doc

# Make sure all persistent objects have _p_jar attribute

# Call manage_renameCode()...