2013/03/07

Set UID for Dexterity Type

When using collective.disqus in Plone, Disqus API by default looks for UID to identify the posts (comments). For the case to manually migrate Archetypes items, I need to set UID property for Dexterity items. Here is how it works:

$ bin/plonectl debug

>>> from plone.uuid.interfaces import IUUID
>>> IUUID(app.mysite.myfolder['a-sample-item'])
'870c668b918247ef89645a6e18007a96'
>>> from plone.uuid.interfaces import ATTRIBUTE_NAME
>>> setattr(app.mysite.myfolder['a-sample-item'], ATTRIBUTE_NAME, 'bc8a2fac032e4ae39c700730ac79df8f')
>>> IUUID(app.mysite.myfolder['a-sample-item'])
'bc8a2fac032e4ae39c700730ac79df8f'
>>> import transaction
>>> transaction.commit()

Of course, transmogrifer would be more decent way for such case.

No comments: