Commit e7a50455 authored by iv's avatar iv

ERP5Workflow: fix installation of bt when objects to install are Persistent Mapping Folders

parent 6bef463e
......@@ -94,6 +94,8 @@ from ZODB.broken import Broken, BrokenModified
from Products.ERP5.genbt5list import BusinessTemplateRevision, \
item_name_list, item_set
from Products.ERP5Type.Core.Folder import PERSISTENT_MAPPING_HANDLER
CACHE_DATABASE_PATH = None
try:
if int(os.getenv('ERP5_BT5_CACHE', 0)):
......@@ -1368,15 +1370,21 @@ class ObjectTemplateItem(BaseTemplateItem):
# because they change when we add subobjects
groups[path] = deepcopy(obj.groups)
# copy the object
if (getattr(aq_base(obj), '_mt_index', None) is not None and
obj._count() == 0):
# some btrees were exported in a corrupted state. They're empty but
# their metadata-index (._mt_index) contains entries which in
# Zope 2.12 are used for .objectIds(), .objectValues() and
# .objectItems(). In these cases, force the
LOG('Products.ERP5.Document.BusinessTemplate', WARNING,
'Cleaning corrupted BTreeFolder2 object at %r.' % (path,))
obj._initBTrees()
if getattr(obj, '_folder_handler', None) == PERSISTENT_MAPPING_HANDLER:
# XXX(WORKFLOW): if obj._count(), then, we should export the content
# of the btree folder to the persistent mapping one
obj._cleanup()
obj.__init__(obj.id)
else:
if (getattr(aq_base(obj), '_mt_index', None) is not None and
obj._count() == 0):
# some btrees were exported in a corrupted state. They're empty but
# their metadata-index (._mt_index) contains entries which in
# Zope 2.12 are used for .objectIds(), .objectValues() and
# .objectItems(). In these cases, force the
LOG('Products.ERP5.Document.BusinessTemplate', WARNING,
'Cleaning corrupted BTreeFolder2 object at %r.' % (path,))
obj._initBTrees()
obj = obj._getCopy(container)
self.removeProperties(obj, 0)
__traceback_info__ = (container, object_id, obj)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment