zupo
zupo

Reputation: 1556

Set UID for Dexterity type

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?

Upvotes: 4

Views: 327

Answers (1)

Martijn Pieters
Martijn Pieters

Reputation: 1123440

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)

Upvotes: 5

Related Questions