Commit be80a889 authored by Jérome Perrin's avatar Jérome Perrin

Allow to bypass portal type's init script when creating new content (for use with Delivery Builder)

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3899 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent a438f01c
......@@ -59,8 +59,9 @@ class FolderMixIn(ExtensionClass.Base):
security.declareObjectProtected(Permissions.View)
security.declareProtected(Permissions.AddPortalContent, 'newContent')
def newContent(self, id=None, portal_type=None, id_group=None, default=None, method=None, immediate_reindex=0,
container=None,**kw):
def newContent(self, id=None, portal_type=None, id_group=None,
default=None, method=None, immediate_reindex=0,
container=None, bypass_init_script=0, **kw):
"""
Creates a new content
"""
......@@ -74,6 +75,7 @@ class FolderMixIn(ExtensionClass.Base):
self.portal_types.constructContent(type_name=portal_type,
container=container,
id=new_id,
bypass_init_script=bypass_init_script
) # **kw) removed due to CMF bug
new_instance = container[new_id]
if kw != {} : new_instance._edit(force_update=1, **kw)
......@@ -94,7 +96,7 @@ class FolderMixIn(ExtensionClass.Base):
else:
raise TypeError, 'deleteContent only accepts string or list, '\
'not %s' % type(id)
# Automatic ID Generation method
security.declareProtected(Permissions.View, 'generateNewId')
def generateNewId(self,id_group=None,default=None,method=None):
......@@ -329,8 +331,9 @@ be a problem)."""
ob._p_jar.exportFile(ob._p_oid,f)
get_transaction().commit()
security.declareProtected( Permissions.ModifyPortalContent, 'recursiveApply' )
def recursiveApply(self, filter=dummyFilter, method=None, test_after=dummyTestAfter, include=1, REQUEST=None, **kw):
security.declareProtected( Permissions.ModifyPortalContent, 'recursiveApply')
def recursiveApply(self, filter=dummyFilter, method=None,
test_after=dummyTestAfter, include=1, REQUEST=None, **kw):
"""
Apply a method to self and to all children
......
......@@ -133,12 +133,18 @@ class ERP5TypeInformation( FactoryTypeInformation, RoleProviderBase ):
# Agent methods
#
security.declarePublic('constructInstance')
def constructInstance( self, container, id, *args, **kw ):
def constructInstance( self, container, id, bypass_init_script=0, *args, **kw ):
"""
Build a "bare" instance of the appropriate type in
'container', using 'id' as its id. Return the object.
'container', using 'id' as its id.
Call the init_script for the portal_type, unless the
keyword arg __bypass_init_script is set to True.
Returns the object.
"""
ob = FactoryTypeInformation.constructInstance(self, container, id, *args, **kw)
ob = FactoryTypeInformation.constructInstance(
self, container, id, *args, **kw)
if bypass_init_script :
return ob
# Only try to assign roles to secutiry groups if some roles are defined
# This is an optimisation to prevent defining local roles on subobjects
......
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