Commit 27711a6b authored by Sebastien Robin's avatar Sebastien Robin

allow to specify a container in newContent


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@2090 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent cee33222
...@@ -58,20 +58,23 @@ class FolderMixIn(ExtensionClass.Base): ...@@ -58,20 +58,23 @@ class FolderMixIn(ExtensionClass.Base):
security.declareObjectProtected(Permissions.View) security.declareObjectProtected(Permissions.View)
security.declareProtected(Permissions.AddPortalContent, 'newContent') security.declareProtected(Permissions.AddPortalContent, 'newContent')
def newContent(self, id=None, portal_type=None, id_group=None, default=None, method=None, immediate_reindex=0, **kw): def newContent(self, id=None, portal_type=None, id_group=None, default=None, method=None, immediate_reindex=0,
container=None,**kw):
""" """
Creates a new content Creates a new content
""" """
if container is None:
container = self
if id is None: if id is None:
new_id = str(self.generateNewId(id_group = id_group, default=default, method=method)) new_id = str(container.generateNewId(id_group = id_group, default=default, method=method))
else: else:
new_id = str(id) new_id = str(id)
if portal_type is None: portal_type = self.allowedContentTypes()[0].id if portal_type is None: portal_type = container.allowedContentTypes()[0].id
self.portal_types.constructContent(type_name=portal_type, self.portal_types.constructContent(type_name=portal_type,
container=self, container=container,
id=new_id, id=new_id,
) # **kw) removed due to CMF bug ) # **kw) removed due to CMF bug
new_instance = self[new_id] new_instance = container[new_id]
if kw is not None: new_instance._edit(force_update=1, **kw) if kw is not None: new_instance._edit(force_update=1, **kw)
if immediate_reindex: new_instance.immediateReindexObject() if immediate_reindex: new_instance.immediateReindexObject()
return new_instance return new_instance
......
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