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,10 +79,18 @@ class VirtualFolderMixin: ...@@ -79,10 +79,18 @@ class VirtualFolderMixin:
""" """
XXX XXX
""" """
tv = getTransactionalVariable() if 'no_traversal' in kw:
document_url = tv.get((id,), None) no_traversal = kw['no_traversal']
if document_url is not None: # remove from kw for later call to _getOb
return self.getPortalObject().unrestrictedTraverse(document_url) 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: try:
return Folder._getOb(self, id, default=default, **kw) 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