Commit 0c8c7611 authored by Jérome Perrin's avatar Jérome Perrin

Use allowType in newContent to check if we can create content.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@12825 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 8d3b00b7
......@@ -77,6 +77,7 @@ class FolderMixIn(ExtensionClass.Base):
This method is public, since TypeInformation.constructInstance will perform
the security check.
"""
pt = self._getTypesTool()
if container is None:
container = self
if id is None:
......@@ -99,7 +100,12 @@ class FolderMixIn(ExtensionClass.Base):
m = getattr(Document, factory_name)
return m(container, new_id)
self.portal_types.constructContent(type_name=portal_type,
myType = pt.getTypeInfo(self)
if myType is not None:
if not myType.allowType( portal_type ):
raise ValueError('Disallowed subobject type: %s' % portal_type)
pt.constructContent( type_name=portal_type,
container=container,
id=new_id,
created_by_builder=created_by_builder,
......
......@@ -147,6 +147,11 @@ class TestFolder(ERP5TypeTestCase, LogInterceptor):
self._assertAllowedContentTypes(self.other_folder, [])
self._assertAllowedContentTypes(self.folder, type_list)
def test_NewContentAndAllowedContentTypes(self):
self._setAllowedContentTypesForFolderType(('Folder', ))
self.assertRaises(ValueError, self.folder.newContent,
portal_type='Category')
if __name__ == '__main__':
framework()
else:
......
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