Commit 7ac5cd93 authored by Thomas Gambier's avatar Thomas Gambier 🚴🏼

fix install of business template

in case a container is a WebSite, container._getOb("id") can return any object
with id "id". If object returned is not inside container, later
container.manage_delObjects([object_id]) will fail with KeyError.
parent f1ee1046
...@@ -1347,7 +1347,12 @@ class ObjectTemplateItem(BaseTemplateItem): ...@@ -1347,7 +1347,12 @@ class ObjectTemplateItem(BaseTemplateItem):
saved_uid_dict = {} saved_uid_dict = {}
subobjects_dict = {} subobjects_dict = {}
portal_type_dict = {} portal_type_dict = {}
old_obj = container._getOb(object_id, None) try:
old_obj = container._getOb(id=object_id, default=None, no_traversal=True)
except TypeError:
# if TypeError raised, it means we are using _getOb from Zope
# components without **kw arg. Retry without invalid arg then.
old_obj = container._getOb(id=object_id, default=None)
object_existed = old_obj is not None object_existed = old_obj is not None
if object_existed: if object_existed:
if context.isKeepObject(path) and force: if context.isKeepObject(path) and force:
......
...@@ -79,6 +79,14 @@ class VirtualFolderMixin: ...@@ -79,6 +79,14 @@ class VirtualFolderMixin:
""" """
XXX XXX
""" """
if 'no_traversal' in kw:
no_traversal = kw['no_traversal']
# remove from kw for later call to _getOb
del kw['no_traversal']
else:
no_traveral = False
if not no_traversal:
tv = getTransactionalVariable() tv = getTransactionalVariable()
document_url = tv.get((id,), None) document_url = tv.get((id,), None)
if document_url is not None: if document_url is not None:
......
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