Improper indexing of UID of DX content

As part of a migration to Plone 5.0 we encounter the following misbehaviour:

A standard Plone Folder

>>> doc = app.restrictedTraverse('/share_20171025-144751/hrz')
>>> doc.portal_type
>>> doc.__class__
<class ''>
>>> doc.UID

has the given UID (which is assigned by the migration process to the created folder in order to retain the original UID (because of existing links in RichText fields).

However this folder is object in portal_catalog with a completely different UID:

We assign the "old" UID like this in our migration script:

folder = plone.api.content.create(...)
folder.UID = old_uid    # 1eda85a66b1c919616f2ad88649952e2

So assigning a new UID does not seem to override the original UID of the freshly created I missing something?


The UID may not be where you expect it to be.

I would check which UUID this function is returning:

from plone.uuid.interfaces import IUUID

In some migrations I had to use this code to fix the UID:

setattr(, '_plone.uuid', getattr(self.old, '_at_uid'))

Yeah, I figured that also out. Somewhere I found a method with explicit getter and setter() methods for the UID property. But plone.uuid is king here.