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