diff --git a/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/ERP5Folder_getUnrestrictedContentTypeList.xml b/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/ERP5Folder_getUnrestrictedContentTypeList.xml index 4dd404919f78a9420d15c0a2258640e83936cc8e..211fb302f33b5beb55e179a3183ad2b4cbf767bf 100644 --- a/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/ERP5Folder_getUnrestrictedContentTypeList.xml +++ b/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/ERP5Folder_getUnrestrictedContentTypeList.xml @@ -56,9 +56,7 @@ <value> <string>"""\n Get portal type list allowed in module through Types Tool\n """\n -folder_portal_type = context.getPortalType()\n -portal = context.getPortalObject()\n -return portal.portal_types[folder_portal_type].allowed_content_types[:]\n +return context.getTypeInfo().getTypeAllowedContentTypeList()\n </string> </value> </item> <item> @@ -105,9 +103,6 @@ return portal.portal_types[folder_portal_type].allowed_content_types[:]\n <tuple> <string>_getattr_</string> <string>context</string> - <string>folder_portal_type</string> - <string>portal</string> - <string>_getitem_</string> </tuple> </value> </item> diff --git a/bt5/erp5_base/bt/revision b/bt5/erp5_base/bt/revision index 5c0d33d75a61e20f229801fedcba649fad7ca175..70e36030cf466a23c1274d793ea72cccdb0fe45b 100644 --- a/bt5/erp5_base/bt/revision +++ b/bt5/erp5_base/bt/revision @@ -1 +1 @@ -647 \ No newline at end of file +648 \ No newline at end of file diff --git a/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/DeliveryModule_getMovementPortalTypeItemList.xml b/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/DeliveryModule_getMovementPortalTypeItemList.xml index 812b4c7f56b52b6a4a6d4035ff9487b3d7457722..b8be0dd83587ff0ab497cf61a6b4e9716719b077 100644 --- a/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/DeliveryModule_getMovementPortalTypeItemList.xml +++ b/bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/DeliveryModule_getMovementPortalTypeItemList.xml @@ -58,11 +58,11 @@ types_tool = context.getPortalObject().portal_types\n movement_type_list = context.getPortalMovementTypeList()\n type_set = dict()\n \n -for type_name in types_tool.getTypeInfo(context).allowed_content_types:\n - for line_type_name in types_tool.getTypeInfo(type_name).allowed_content_types:\n +for type_name in types_tool.getTypeInfo(context).getTypeAllowedContentTypeList():\n + for line_type_name in types_tool.getTypeInfo(type_name).getTypeAllowedContentTypeList():\n if line_type_name in movement_type_list:\n type_set[line_type_name] = 1\n - for cell_type_name in types_tool.getTypeInfo(line_type_name).allowed_content_types:\n + for cell_type_name in types_tool.getTypeInfo(line_type_name).getTypeAllowedContentTypeList():\n if cell_type_name in movement_type_list:\n type_set[cell_type_name] = 1\n \n diff --git a/bt5/erp5_trade/bt/revision b/bt5/erp5_trade/bt/revision index 475fbacb43f1e37932f5cd9aa9ba871e283891c2..5d5ad96f9fa59e86a02bf299511221da15f5511a 100644 --- a/bt5/erp5_trade/bt/revision +++ b/bt5/erp5_trade/bt/revision @@ -1 +1 @@ -763 \ No newline at end of file +764 \ No newline at end of file diff --git a/bt5/erp5_web/ActionTemplateItem/portal_types/Web%20Section/local_permission.xml b/bt5/erp5_web/ActionTemplateItem/portal_types/Web%20Section/local_permission.xml index 8caf266d6ccb838256cc1fd677ad59d3715264ec..d02adeab886d95f6ac47bab21b4b5bf2c3e17e5d 100644 --- a/bt5/erp5_web/ActionTemplateItem/portal_types/Web%20Section/local_permission.xml +++ b/bt5/erp5_web/ActionTemplateItem/portal_types/Web%20Section/local_permission.xml @@ -95,7 +95,7 @@ <dictionary> <item> <key> <string>text</string> </key> - <value> <string>python: \'Role Definition\' in portal.portal_types[\'Web Section\'].allowed_content_types</string> </value> + <value> <string>python: \'Role Definition\' in portal.portal_types[\'Web Section\'].getTypeAllowedContentTypeList()</string> </value> </item> </dictionary> </pickle> diff --git a/bt5/erp5_web/ActionTemplateItem/portal_types/Web%20Site/local_permission.xml b/bt5/erp5_web/ActionTemplateItem/portal_types/Web%20Site/local_permission.xml index 4bb7c5d6102282d8fedd43924bff763a3e75503e..187892b38fede34575e9b2a502653f8221d49c40 100644 --- a/bt5/erp5_web/ActionTemplateItem/portal_types/Web%20Site/local_permission.xml +++ b/bt5/erp5_web/ActionTemplateItem/portal_types/Web%20Site/local_permission.xml @@ -95,7 +95,7 @@ <dictionary> <item> <key> <string>text</string> </key> - <value> <string>python: \'Role Definition\' in portal.portal_types[\'Web Site\'].allowed_content_types</string> </value> + <value> <string>python: \'Role Definition\' in portal.portal_types[\'Web Site\'].getTypeAllowedContentTypeList()</string> </value> </item> </dictionary> </pickle> diff --git a/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/WebSite_calculateStatistics.xml b/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/WebSite_calculateStatistics.xml index 537a03d8a2704104fa5dab9a19b7ff6906936f47..3721723ca5205935cf0cd6fa57d62a12c8f07623 100644 --- a/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/WebSite_calculateStatistics.xml +++ b/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/WebSite_calculateStatistics.xml @@ -78,7 +78,7 @@ def calculateStatistics():\n documents_groups = {}\n documents_owners = {}\n documents_classifications = {}\n - document_content_types = portal_types[\'Document Module\'].allowed_content_types\n + document_content_types = portal_types[\'Document Module\'].getTypeAllowedContentTypeList()\n all_documents = portal_catalog.searchResults(portal_type = document_content_types)\n total_documents = portal_catalog.countResults(portal_type = document_content_types)[0][0]\n total_documents_released = portal_catalog.countResults(portal_type = document_content_types,\n diff --git a/bt5/erp5_web/bt/revision b/bt5/erp5_web/bt/revision index 0aa5559ec43f0adcc195ff1f3f4fb12e4aa1c42b..bbff031a29f577ecf9bb9e61a269b88e828da762 100644 --- a/bt5/erp5_web/bt/revision +++ b/bt5/erp5_web/bt/revision @@ -1 +1 @@ -866 \ No newline at end of file +867 \ No newline at end of file diff --git a/product/ERP5/tests/testDeliveryBuilderToSupportMultipleLines.py b/product/ERP5/tests/testDeliveryBuilderToSupportMultipleLines.py index d66928ac55141264d88631801b6c63b445f72de6..04be71d34ad4348e151818633fac2bf993f78eae 100644 --- a/product/ERP5/tests/testDeliveryBuilderToSupportMultipleLines.py +++ b/product/ERP5/tests/testDeliveryBuilderToSupportMultipleLines.py @@ -68,8 +68,9 @@ class TestNestedLineMixin(TestSaleInvoiceMixin): def _allowInvoiceLineContentTypeInInvoiceLine(self): invoice_line_type = self.portal.portal_types['Invoice Line'] - if 'Invoice Line' not in invoice_line_type.allowed_content_types: - invoice_line_type.allowed_content_types += ('Invoice Line',) + content_type_set = set(invoice_line_type.getTypeAllowedContentTypeList()) + content_type_set.add('Invoice Line') + invoice_line_type._setTypeAllowedContentTypeList(tuple(content_type_set)) def stepGetRelatedInvoiceFromPackingList(self, sequence, **kw): packing_list = sequence.get('packing_list') diff --git a/product/ERP5/tests/testDomainTool.py b/product/ERP5/tests/testDomainTool.py index d8e821f7a7bdc76aea1931f1d02803645dfbebec..80df378d480e211c6152d7fa4de247740f0426bd 100644 --- a/product/ERP5/tests/testDomainTool.py +++ b/product/ERP5/tests/testDomainTool.py @@ -74,11 +74,11 @@ class TestDomainTool(TestPredicateMixIn): def createData(self): # We have no place to put a Predicate, we will put it in a # Organisation Module - portal = self.getPortal() - type_tool = self.getTypeTool() - module_type = type_tool['Organisation Module'] - module_type.allowed_content_types += ('Mapped Value',) organisation_module = self.getOrganisationModule() + module_type = organisation_module.getTypeInfo() + content_type_set = set(module_type.getTypeAllowedContentTypeList()) + content_type_set.add('Mapped Value') + module_type._setTypeAllowedContentTypeList(tuple(content_type_set)) if organisation_module.hasContent('1'): organisation_module.deleteContent('1') predicate = organisation_module.newContent(id='1',portal_type='Mapped Value') diff --git a/product/ERP5/tests/testERP5Category.py b/product/ERP5/tests/testERP5Category.py index ce4c405780f7ea6accfb6dfef821bb469db638aa..dbd5d28ab47fd2f986a92a2e3fd6e44569063a4a 100644 --- a/product/ERP5/tests/testERP5Category.py +++ b/product/ERP5/tests/testERP5Category.py @@ -37,7 +37,6 @@ class TestERP5Category(ERP5TypeTestCase): # Different variables used for this test run_all_test = 1 quiet = 1 - portal_type = 'Organisation' base_cat = 'abc' base_cat2 = 'efg' cat_list = [base_cat + '/1',base_cat + '/2'] @@ -88,21 +87,21 @@ class TestERP5Category(ERP5TypeTestCase): self.deep_cat2 = self.cat2['1'] # associate base categories on Organisation portal type - portal_type = self.getTypeTool()[self.portal_type] - portal_type._setTypeBaseCategoryList([self.base_cat, self.base_cat2]) + type_info = self.getTypeTool().Organisation + type_info._setTypeBaseCategoryList([self.base_cat, self.base_cat2]) # Reset aq dynamic _aq_reset() organisation_module = self.getOrganisationModule() if not organisation_module.has_key('1'): - organisation_module.newContent(id='1', portal_type=self.portal_type) + organisation_module.newContent(id='1', portal_type='Organisation') self.organisation = organisation_module['1'] if not self.organisation.has_key('1'): self.organisation.newContent(id='1', portal_type='Telephone') self.telephone = self.organisation['1'] if not organisation_module.has_key('2'): - organisation_module.newContent(id='2', portal_type=self.portal_type) + organisation_module.newContent(id='2', portal_type='Organisation') self.organisation2 = organisation_module['2'] if not self.organisation2.has_key('1'): self.organisation2.newContent(id='1', portal_type='Telephone') @@ -129,14 +128,13 @@ class TestERP5Category(ERP5TypeTestCase): # We have no place to put a Predicate, we will put it in the # Organisation Module - portal = self.getPortal() - type_tool = self.getTypeTool() - module_type = type_tool['%s Module' % self.portal_type] - module_type.allowed_content_types += ('Mapped Value',) - module = self.getOrganisationModule() - if not module.has_key('predicate'): - module.newContent(id='predicate', portal_type='Mapped Value') - predicate = module['predicate'] + module_type = organisation_module.getTypeInfo() + content_type_set = set(module_type.getTypeAllowedContentTypeList()) + content_type_set.add('Mapped Value') + module_type._setTypeAllowedContentTypeList(tuple(content_type_set)) + if not organisation_module.has_key('predicate'): + organisation_module.newContent(id='predicate', portal_type='Mapped Value') + predicate = organisation_module['predicate'] predicate.setCriterion('quantity', identity=None, min=None, max=None) self.predicate = predicate diff --git a/product/ERP5/tests/testTemplate.py b/product/ERP5/tests/testTemplate.py index b0fe4da76043bf6f09d8fede3335819f45d32244..26df73ea11445b9e41d53c12cc7a5f65961e8faf 100644 --- a/product/ERP5/tests/testTemplate.py +++ b/product/ERP5/tests/testTemplate.py @@ -63,7 +63,8 @@ class TestTemplate(ERP5TypeTestCase): portal_preferences.deleteContent(list(portal_preferences.objectIds())) transaction.commit() self.tic() - self.portal.portal_types['Preference'].allowed_content_types = ('Foo', 'Knowledge Pad') + self.portal.portal_types.Preference._setTypeAllowedContentTypeList( + ('Foo', 'Knowledge Pad')) self.portal.foo_module.manage_role(role_to_manage='Author', permissions=[Permissions.AddPortalContent, Permissions.CopyOrMove, diff --git a/product/ERP5Form/Extensions/Folder_viewSearchDialog.py b/product/ERP5Form/Extensions/Folder_viewSearchDialog.py index a9b4286c07e831171d16fd1319b71e7b21de189d..afb94c187d7e1fec602bed52d1e4ffbbfb80e543 100644 --- a/product/ERP5Form/Extensions/Folder_viewSearchDialog.py +++ b/product/ERP5Form/Extensions/Folder_viewSearchDialog.py @@ -264,8 +264,8 @@ def getSearchDialog(self, REQUEST=None): default_search_key=default_search_key) # TODO always add SearchableText ? - - allowed_content_types = types_tool.getTypeInfo(self).allowed_content_types + + allowed_content_types = self.getTypeInfo().getTypeAllowedContentTypeList() # remember which workflow we already displayed workflow_dict = dict() # possible workflow states diff --git a/product/ERP5Form/ScribusUtils.py b/product/ERP5Form/ScribusUtils.py index 30b7b46f1c36ae683e5cd411e07b7a141b44ef51..8d983e7ecc52292475821525241ae9cf1aa0f99b 100644 --- a/product/ERP5Form/ScribusUtils.py +++ b/product/ERP5Form/ScribusUtils.py @@ -405,9 +405,10 @@ class ManageModule: , id = module_portal_type) # getting portal_type access to be able to modify attributes module_portal_type_value = portal_types[module_portal_type] - # set alowed content type - module_portal_type_value.allowed_content_types = (object_portal_type_id,) - module_portal_type_value.filter_content_types = 1 + # set allowed content type + module_portal_type_value.edit( + type_allowed_content_type_list=(object_portal_type_id,), + type_filter_content_type=1) # adding usefull actions (in our case the view action) module_portal_type_value.newContent(portal_type='Action Information', reference="view", diff --git a/product/ERP5Type/patches/CMFBTreeFolder.py b/product/ERP5Type/patches/CMFBTreeFolder.py index e64898707ad20c6191f893f3159c7c38f6a94365..c6acdeed724fd5003364dbc9dc741615f6a2364a 100644 --- a/product/ERP5Type/patches/CMFBTreeFolder.py +++ b/product/ERP5Type/patches/CMFBTreeFolder.py @@ -39,7 +39,7 @@ def CMFBTreeFolder_allowedContentTypes(self): if myType is not None: allowed_types_to_check = [] if myType.filter_content_types: - for portal_type in myType.allowed_content_types: + for portal_type in myType.getTypeAllowedContentTypeList(): contentType = portal_types.getTypeInfo(portal_type) if contentType is None: raise AttributeError, "Portal type '%s' does not exist " \ diff --git a/product/ERP5Type/tests/testConstraint.py b/product/ERP5Type/tests/testConstraint.py index f4d73c33a2e5b7d0323667d9bdb973dbfa4d7682..3544cd8ecb7aac4ebba0a6379e8eecc5d8b408fb 100644 --- a/product/ERP5Type/tests/testConstraint.py +++ b/product/ERP5Type/tests/testConstraint.py @@ -1244,15 +1244,15 @@ class TestConstraint(PropertySheetTestCase): # this property suppose that we can add some Organisation inside # Organisation, so we temporary patch the type information. ti = self.getTypesTool().getTypeInfo(obj) - allowed_types = list(ti.allowed_content_types) - ti.allowed_content_types = allowed_types + ['Organisation'] + allowed_types = ti.getTypeAllowedContentTypeList() + ti._setTypeAllowedContentTypeList(allowed_types + ['Organisation']) try: constraint.fixConsistency(obj) self.assertEquals('foo', obj.getDefaultOrganisationTitle()) self.assertEquals('foo', obj.default_organisation.getTitle()) finally: - ti.allowed_content_types = tuple(allowed_types) - + ti._setTypeAllowedContentTypeList(allowed_types) + def test_PropertyTypeValidityFixLocalPropertiesForCategories(self): """Tests PropertyTypeValidity can repairs categories when this property is added on the class later. diff --git a/product/ERP5Type/tests/testERP5Type.py b/product/ERP5Type/tests/testERP5Type.py index 03ad73ed58a5067b4281352f5505a7676890652a..185aafe250afa369f20e42962115168182d5f309 100644 --- a/product/ERP5Type/tests/testERP5Type.py +++ b/product/ERP5Type/tests/testERP5Type.py @@ -2449,10 +2449,10 @@ class TestPropertySheet: 'Test Add Permission Document') # allow this type info in Person Module - container_type_info = self.portal.portal_types.getTypeInfo('Person Module') - container_type_info.allowed_content_types = tuple( - container_type_info.allowed_content_types) + ( - 'Test Add Permission Document', ) + container_type_info = self.getTypesTool().getTypeInfo('Person Module') + container_type_info._setTypeAllowedContentTypeList( + container_type_info.getTypeAllowedContentTypeList() + + ['Test Add Permission Document']) # by default this is empty, which implictly means "Add portal content", # the default permission diff --git a/product/ERP5Type/tests/testFolder.py b/product/ERP5Type/tests/testFolder.py index b6182f901409311e144fd24296fa8a58fef3bf70..88ef73f3bb2b08680d72418c25475e28590d628b 100644 --- a/product/ERP5Type/tests/testFolder.py +++ b/product/ERP5Type/tests/testFolder.py @@ -123,25 +123,17 @@ class TestFolder(ERP5TypeTestCase, LogInterceptor): obj = self.newContent() self.assertEquals(obj.getId(), id_generator_id_list[expected_length]) - def _setAllowedContentTypesForFolderType(self, allowed_content_types): + def _setAllowedContentTypesForFolderType(self, allowed_content_type_list): """Set allowed content types for Folder portal type.""" - folder_ti = self.getTypesTool()['Folder'] - folder_ti.allowed_content_types = allowed_content_types - folder_ti.filter_content_types = True - + self.getTypesTool().Folder.edit( + type_allowed_content_type_list=allowed_content_type_list, + type_filter_content_type=True) + def _assertAllowedContentTypes(self, obj, expected_allowed_content_types): """Asserts that allowed content types for obj are exactly what we have in expected_allowed_content_types.""" - allowed_content_types_id_list = [x.getId() for - x in obj.allowedContentTypes()] - self.assertEquals(len(expected_allowed_content_types), - len(allowed_content_types_id_list), - 'expected %s and actual %s have different length' % ( - expected_allowed_content_types, - allowed_content_types_id_list - )) - for portal_type_name in expected_allowed_content_types: - self.failUnless(portal_type_name in allowed_content_types_id_list) + self.assertEqual(sorted(expected_allowed_content_types), + sorted(x.getId() for x in obj.allowedContentTypes())) def test_AllowedContentTypes(self): type_list = ['Folder', 'Category', 'Base Category']