You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
These are two distinct issues — both with ContentExport (Plone 5.1, Python 2.7.18, collective.exportimport == 1.7, plone.restapi==7.8.0,) — but I'm using a common monkey patch to work around them, so I figured I would make an issue, if for nothing else, to get this discussion somewhere outside just my own head:
A content item with CMFEditions history containing an item ID rename will not export, because Next/Previous serialization of plone.restapi attempts to get a position (both next, and previous) in container for an id that is no longer there, which fails with something like ValueError: 'OLD_ID_IS_HERE_BUT_CONTAINER_DOES_NOT_GET_IT' is not in list.
If a content item's creator is no longer an existing Plone user, plone.restapi locking serialization fails with AttributeError: 'NoneType' object has no attribute 'getProperty'.
I ended up monkey patching in my export runscript to work around these two things:
fromplone.app.dexterity.behaviors.nextpreviousimportNextPreviousBaseimportplone.restapi# monkey patch plone.app.dexterity.behaviors.nextprevious to handle# CMFEditions revision objects that have had an id rename, robustly# for collective.exportimport use case:orig_get_next=NextPreviousBase.getNextItemorig_get_prev=NextPreviousBase.getPreviousItemorig_creator_name=plone.restapi.services.locking.creator_namedefforgiving_call(orig):
def_inner(*args):
try:
returnorig(*args)
except (ValueError, AttributeError):
# for next/previous serializing:# the object isn't in the parent, probably because its id was# renamed, and plone.restapi.serializer.nextprev.NextPrevious# is trying to serialize a fetched historic CMFEditions# revision of the object to serialize, and that historic# version has the old ID no longer in the parent container# for creator_name for locking:# need to be robust around a creator who is no longer in system# as a plone userreturnNonereturn_innerNextPreviousBase.getNextItem=forgiving_call(orig_get_next)
NextPreviousBase.getPreviousItem=forgiving_call(orig_get_prev)
plone.restapi.services.locking.creator_name=forgiving_call(orig_creator_name)
I am unsure about how to address these in a "safe for use outside my limited-purpose runscript" because monkey patching these is a change in behavior for multiple places in plone.restapi, and my use-case is limited to making my export work without omitting content. But content will not export reliably in either condition described above for me without doing this.
The text was updated successfully, but these errors were encountered:
These are two distinct issues — both with ContentExport (Plone 5.1, Python 2.7.18,
collective.exportimport == 1.7
,plone.restapi==7.8.0
,) — but I'm using a common monkey patch to work around them, so I figured I would make an issue, if for nothing else, to get this discussion somewhere outside just my own head:ValueError: 'OLD_ID_IS_HERE_BUT_CONTAINER_DOES_NOT_GET_IT' is not in list
.AttributeError: 'NoneType' object has no attribute 'getProperty'
.I ended up monkey patching in my export runscript to work around these two things:
I am unsure about how to address these in a "safe for use outside my limited-purpose runscript" because monkey patching these is a change in behavior for multiple places in
plone.restapi
, and my use-case is limited to making my export work without omitting content. But content will not export reliably in either condition described above for me without doing this.The text was updated successfully, but these errors were encountered: