Question

I'm migrating content from Archetypes to Dexterity and I need the new items to have the same UID as the old ones.

On Archetypes items I can call context._setUID('my-uid'). Is there something similar for Dexterity?

Was it helpful?

Solution

For Dexterity UUID values, the plone.uuid package is used. plone.uuid simply stores the value in a attribute.

The following suffices to set a predetermined UUID on an existing Dexterity object obj:

from plone.uuid.interfaces import ATTRIBUTE_NAME

setattr(obj, ATTRIBUTE_NAME, uuid)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top