4

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?

zupo
  • 1,556
  • 1
  • 13
  • 17

1 Answers1

5

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)
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
  • We should probably add a plone.uuid.interfaces.IMutableUUID adapter for Archetypes content so that that interface can be used for all content. – David Glick Feb 20 '13 at 00:02