Commit 65510366 authored by Nicolas Dumazet's avatar Nicolas Dumazet

* extend importObjectFromFile API to pass suppress_events to _setObject

* make sure that when set_owner=False, nothing is tried on owernships at all

suppress_events=True or a call to manage_changeOwnershipType implies
a recursion in the imported objects, forcing portal type classes loads to
be able to return subojects: sometimes we do not want this.

This is required to be able to import XML files very early in the bootstrap
process without having zope to EVER recurse into the imported objects:
when installing portal_types/portal_property_sheets for bootstrap, we
  a) do not care about ownership
  b) do not care about oh-so-clever zope events



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@42396 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 08ba0513
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
# Import: add rename feature and make _importObjectFromFile return the object # Import: add rename feature and make _importObjectFromFile return the object
from OFS.ObjectManager import ObjectManager, customImporters from OFS.ObjectManager import ObjectManager, customImporters
def ObjectManager_importObjectFromFile(self, filepath, verify=1, set_owner=1, id=None): def ObjectManager_importObjectFromFile(self, filepath, verify=1, set_owner=1, id=None, suppress_events=False):
#LOG('_importObjectFromFile, filepath',0,filepath) #LOG('_importObjectFromFile, filepath',0,filepath)
# locate a valid connection # locate a valid connection
connection=self._p_jar connection=self._p_jar
...@@ -30,12 +30,13 @@ def ObjectManager_importObjectFromFile(self, filepath, verify=1, set_owner=1, id ...@@ -30,12 +30,13 @@ def ObjectManager_importObjectFromFile(self, filepath, verify=1, set_owner=1, id
if id is None: if id is None:
id=ob.id id=ob.id
if hasattr(id, 'im_func'): id=id() if hasattr(id, 'im_func'): id=id()
self._setObject(id, ob, set_owner=set_owner) self._setObject(id, ob, set_owner=set_owner, suppress_events=suppress_events)
# try to make ownership implicit if possible in the context # try to make ownership implicit if possible in the context
# that the object was imported into. # that the object was imported into.
ob=self._getOb(id) ob=self._getOb(id)
ob.manage_changeOwnershipType(explicit=0) if set_owner:
ob.manage_changeOwnershipType(explicit=0)
return ob return ob
ObjectManager._importObjectFromFile=ObjectManager_importObjectFromFile ObjectManager._importObjectFromFile=ObjectManager_importObjectFromFile
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