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):
saved_uid_dict = {}
subobjects_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
if object_existed:
if context.isKeepObject(path) and force:
......
......@@ -79,10 +79,18 @@ class VirtualFolderMixin:
"""
XXX
"""
tv = getTransactionalVariable()
document_url = tv.get((id,), None)
if document_url is not None:
return self.getPortalObject().unrestrictedTraverse(document_url)
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()
document_url = tv.get((id,), None)
if document_url is not None:
return self.getPortalObject().unrestrictedTraverse(document_url)
try:
return Folder._getOb(self, id, default=default, **kw)
......
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