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