I recently had a problem where a folderish object (with some files and pages in it) had an export size of 34GB. After some days of tedious analysis, I noticed that unrelated content gets exported as well. I tracked it down to 2 fields (RelationLists), each having one RelationValue-element with a “wrong” __parent__
set (to some dangling object within the DB). It looks like Relations not handled for folderish content · Issue #118 · plone/plone.app.iterate · GitHub is the cause of this. However, I would like to know if there are other objects with a huge export/copy-size. Is there any way to identify a “wrong” parent?
I started with a script but it gave me out 10000 wrong parents (out of 95000) and many of them don’t have a huge size when exporting.
Script to identify wrong parents
This is the most important part of the script. Before this I use the Catalog to access the find the objects, access them and check the fields with relationvalues/lists.
def analyse_relation(self, rel_item, obj):
if not rel_item:
return True
if not IRelationValue.providedBy(rel_item):
return True
if obj.portal_type in ["File", "Image"]:
grandparent_is_set_as_parent = (
obj.aq_parent.aq_parent.aq_base == rel_item.__parent__
)
parent_is_set_as_parent = obj.aq_parent == rel_item.__parent__
self_is_set_as_parent = obj == rel_item.__parent__
return (
grandparent_is_set_as_parent
or parent_is_set_as_parent
or self_is_set_as_parent
)
return rel_item.__parent__ == obj