Commit 66cb9c96 authored by Julien Muchembled's avatar Julien Muchembled

Make newContent call _edit sooner (before computing local roles)

parent 7f7cc0cf
......@@ -112,9 +112,7 @@ class FolderMixIn(ExtensionClass.Base):
security.declarePublic('newContent')
def newContent(self, id=None, portal_type=None, id_group=None,
default=None, method=None, container=None, created_by_builder=0,
activate_kw=None, is_indexable=None, temp_object=0, reindex_kw=None,
compute_local_role=None, notify_workflow=True, **kw):
default=None, method=None, container=None, temp_object=0, **kw):
"""Creates a new content.
This method is public, since TypeInformation.constructInstance will perform
the security check.
......@@ -157,21 +155,10 @@ class FolderMixIn(ExtensionClass.Base):
new_instance = type_info.constructInstance(
container=container,
id=new_id,
created_by_builder=created_by_builder,
temp_object=temp_object or temp_container,
activate_kw=activate_kw,
reindex_kw=reindex_kw,
is_indexable=is_indexable,
compute_local_role=compute_local_role,
notify_workflow=notify_workflow,
) # **kw) removed due to CMF bug
# TODO :the **kw makes it impossible to create content not based on
# ERP5TypeInformation, because factory method often do not support
# keywords arguments.
**kw)
if temp_container:
container._setObject(new_id, new_instance.aq_base)
if kw:
new_instance._edit(force_update=1, **kw)
return new_instance
security.declareProtected(
......
......@@ -353,7 +353,7 @@ class ERP5TypeInformation(XMLObject,
security.declarePublic('constructInstance')
def constructInstance(self, container, id, created_by_builder=0,
temp_object=0, compute_local_role=None,
notify_workflow=True, *args, **kw ):
notify_workflow=True, **kw):
"""
Build a "bare" instance of the appropriate type in
'container', using 'id' as its id.
......@@ -396,13 +396,13 @@ class ERP5TypeInformation(XMLObject,
if getattr(aq_base(ob), 'uid', None) is None:
ob.uid = portal.portal_catalog.newUid()
if kw:
ob._edit(force_update=1, **kw)
# Portal type has to be set before setting other attributes
# in order to initialize aq_dynamic
ob.portal_type = self.getId()
if kw:
ob._edit(force_update=1, **kw)
if compute_local_role:
# Do not reindex object because it's already done by manage_afterAdd
self.updateLocalRolesOnDocument(ob, reindex=False)
......@@ -420,7 +420,7 @@ class ERP5TypeInformation(XMLObject,
if init_script:
# Acquire the init script in the context of this object
kw['created_by_builder'] = created_by_builder
getattr(ob, init_script)(*args, **kw)
getattr(ob, init_script)()
return ob
......
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