Commit 7655bef2 authored by Julien Muchembled's avatar Julien Muchembled

Use getTypeAllowedContentTypeList() instead of accessing 'allowed_content_types' directly

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@30224 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b5585104
...@@ -56,9 +56,7 @@ ...@@ -56,9 +56,7 @@
<value> <string>"""\n <value> <string>"""\n
Get portal type list allowed in module through Types Tool\n Get portal type list allowed in module through Types Tool\n
"""\n """\n
folder_portal_type = context.getPortalType()\n return context.getTypeInfo().getTypeAllowedContentTypeList()\n
portal = context.getPortalObject()\n
return portal.portal_types[folder_portal_type].allowed_content_types[:]\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
...@@ -105,9 +103,6 @@ return portal.portal_types[folder_portal_type].allowed_content_types[:]\n ...@@ -105,9 +103,6 @@ return portal.portal_types[folder_portal_type].allowed_content_types[:]\n
<tuple> <tuple>
<string>_getattr_</string> <string>_getattr_</string>
<string>context</string> <string>context</string>
<string>folder_portal_type</string>
<string>portal</string>
<string>_getitem_</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
647 648
\ No newline at end of file \ No newline at end of file
...@@ -58,11 +58,11 @@ types_tool = context.getPortalObject().portal_types\n ...@@ -58,11 +58,11 @@ types_tool = context.getPortalObject().portal_types\n
movement_type_list = context.getPortalMovementTypeList()\n movement_type_list = context.getPortalMovementTypeList()\n
type_set = dict()\n type_set = dict()\n
\n \n
for type_name in types_tool.getTypeInfo(context).allowed_content_types:\n for type_name in types_tool.getTypeInfo(context).getTypeAllowedContentTypeList():\n
for line_type_name in types_tool.getTypeInfo(type_name).allowed_content_types:\n for line_type_name in types_tool.getTypeInfo(type_name).getTypeAllowedContentTypeList():\n
if line_type_name in movement_type_list:\n if line_type_name in movement_type_list:\n
type_set[line_type_name] = 1\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 if cell_type_name in movement_type_list:\n
type_set[cell_type_name] = 1\n type_set[cell_type_name] = 1\n
\n \n
......
763 764
\ No newline at end of file \ No newline at end of file
...@@ -95,7 +95,7 @@ ...@@ -95,7 +95,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>text</string> </key> <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> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -95,7 +95,7 @@ ...@@ -95,7 +95,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>text</string> </key> <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> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -78,7 +78,7 @@ def calculateStatistics():\n ...@@ -78,7 +78,7 @@ def calculateStatistics():\n
documents_groups = {}\n documents_groups = {}\n
documents_owners = {}\n documents_owners = {}\n
documents_classifications = {}\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 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 = portal_catalog.countResults(portal_type = document_content_types)[0][0]\n
total_documents_released = portal_catalog.countResults(portal_type = document_content_types,\n total_documents_released = portal_catalog.countResults(portal_type = document_content_types,\n
......
866 867
\ No newline at end of file \ No newline at end of file
...@@ -68,8 +68,9 @@ class TestNestedLineMixin(TestSaleInvoiceMixin): ...@@ -68,8 +68,9 @@ class TestNestedLineMixin(TestSaleInvoiceMixin):
def _allowInvoiceLineContentTypeInInvoiceLine(self): def _allowInvoiceLineContentTypeInInvoiceLine(self):
invoice_line_type = self.portal.portal_types['Invoice Line'] invoice_line_type = self.portal.portal_types['Invoice Line']
if 'Invoice Line' not in invoice_line_type.allowed_content_types: content_type_set = set(invoice_line_type.getTypeAllowedContentTypeList())
invoice_line_type.allowed_content_types += ('Invoice Line',) content_type_set.add('Invoice Line')
invoice_line_type._setTypeAllowedContentTypeList(tuple(content_type_set))
def stepGetRelatedInvoiceFromPackingList(self, sequence, **kw): def stepGetRelatedInvoiceFromPackingList(self, sequence, **kw):
packing_list = sequence.get('packing_list') packing_list = sequence.get('packing_list')
......
...@@ -74,11 +74,11 @@ class TestDomainTool(TestPredicateMixIn): ...@@ -74,11 +74,11 @@ class TestDomainTool(TestPredicateMixIn):
def createData(self): def createData(self):
# We have no place to put a Predicate, we will put it in a # We have no place to put a Predicate, we will put it in a
# Organisation Module # 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() 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'): if organisation_module.hasContent('1'):
organisation_module.deleteContent('1') organisation_module.deleteContent('1')
predicate = organisation_module.newContent(id='1',portal_type='Mapped Value') predicate = organisation_module.newContent(id='1',portal_type='Mapped Value')
......
...@@ -37,7 +37,6 @@ class TestERP5Category(ERP5TypeTestCase): ...@@ -37,7 +37,6 @@ class TestERP5Category(ERP5TypeTestCase):
# Different variables used for this test # Different variables used for this test
run_all_test = 1 run_all_test = 1
quiet = 1 quiet = 1
portal_type = 'Organisation'
base_cat = 'abc' base_cat = 'abc'
base_cat2 = 'efg' base_cat2 = 'efg'
cat_list = [base_cat + '/1',base_cat + '/2'] cat_list = [base_cat + '/1',base_cat + '/2']
...@@ -88,21 +87,21 @@ class TestERP5Category(ERP5TypeTestCase): ...@@ -88,21 +87,21 @@ class TestERP5Category(ERP5TypeTestCase):
self.deep_cat2 = self.cat2['1'] self.deep_cat2 = self.cat2['1']
# associate base categories on Organisation portal type # associate base categories on Organisation portal type
portal_type = self.getTypeTool()[self.portal_type] type_info = self.getTypeTool().Organisation
portal_type._setTypeBaseCategoryList([self.base_cat, self.base_cat2]) type_info._setTypeBaseCategoryList([self.base_cat, self.base_cat2])
# Reset aq dynamic # Reset aq dynamic
_aq_reset() _aq_reset()
organisation_module = self.getOrganisationModule() organisation_module = self.getOrganisationModule()
if not organisation_module.has_key('1'): 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'] self.organisation = organisation_module['1']
if not self.organisation.has_key('1'): if not self.organisation.has_key('1'):
self.organisation.newContent(id='1', portal_type='Telephone') self.organisation.newContent(id='1', portal_type='Telephone')
self.telephone = self.organisation['1'] self.telephone = self.organisation['1']
if not organisation_module.has_key('2'): 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'] self.organisation2 = organisation_module['2']
if not self.organisation2.has_key('1'): if not self.organisation2.has_key('1'):
self.organisation2.newContent(id='1', portal_type='Telephone') self.organisation2.newContent(id='1', portal_type='Telephone')
...@@ -129,14 +128,13 @@ class TestERP5Category(ERP5TypeTestCase): ...@@ -129,14 +128,13 @@ class TestERP5Category(ERP5TypeTestCase):
# We have no place to put a Predicate, we will put it in the # We have no place to put a Predicate, we will put it in the
# Organisation Module # Organisation Module
portal = self.getPortal() module_type = organisation_module.getTypeInfo()
type_tool = self.getTypeTool() content_type_set = set(module_type.getTypeAllowedContentTypeList())
module_type = type_tool['%s Module' % self.portal_type] content_type_set.add('Mapped Value')
module_type.allowed_content_types += ('Mapped Value',) module_type._setTypeAllowedContentTypeList(tuple(content_type_set))
module = self.getOrganisationModule() if not organisation_module.has_key('predicate'):
if not module.has_key('predicate'): organisation_module.newContent(id='predicate', portal_type='Mapped Value')
module.newContent(id='predicate', portal_type='Mapped Value') predicate = organisation_module['predicate']
predicate = module['predicate']
predicate.setCriterion('quantity', identity=None, min=None, max=None) predicate.setCriterion('quantity', identity=None, min=None, max=None)
self.predicate = predicate self.predicate = predicate
......
...@@ -63,7 +63,8 @@ class TestTemplate(ERP5TypeTestCase): ...@@ -63,7 +63,8 @@ class TestTemplate(ERP5TypeTestCase):
portal_preferences.deleteContent(list(portal_preferences.objectIds())) portal_preferences.deleteContent(list(portal_preferences.objectIds()))
transaction.commit() transaction.commit()
self.tic() 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', self.portal.foo_module.manage_role(role_to_manage='Author',
permissions=[Permissions.AddPortalContent, permissions=[Permissions.AddPortalContent,
Permissions.CopyOrMove, Permissions.CopyOrMove,
......
...@@ -264,8 +264,8 @@ def getSearchDialog(self, REQUEST=None): ...@@ -264,8 +264,8 @@ def getSearchDialog(self, REQUEST=None):
default_search_key=default_search_key) default_search_key=default_search_key)
# TODO always add SearchableText ? # 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 # remember which workflow we already displayed
workflow_dict = dict() workflow_dict = dict()
# possible workflow states # possible workflow states
......
...@@ -405,9 +405,10 @@ class ManageModule: ...@@ -405,9 +405,10 @@ class ManageModule:
, id = module_portal_type) , id = module_portal_type)
# getting portal_type access to be able to modify attributes # getting portal_type access to be able to modify attributes
module_portal_type_value = portal_types[module_portal_type] module_portal_type_value = portal_types[module_portal_type]
# set alowed content type # set allowed content type
module_portal_type_value.allowed_content_types = (object_portal_type_id,) module_portal_type_value.edit(
module_portal_type_value.filter_content_types = 1 type_allowed_content_type_list=(object_portal_type_id,),
type_filter_content_type=1)
# adding usefull actions (in our case the view action) # adding usefull actions (in our case the view action)
module_portal_type_value.newContent(portal_type='Action Information', module_portal_type_value.newContent(portal_type='Action Information',
reference="view", reference="view",
......
...@@ -39,7 +39,7 @@ def CMFBTreeFolder_allowedContentTypes(self): ...@@ -39,7 +39,7 @@ def CMFBTreeFolder_allowedContentTypes(self):
if myType is not None: if myType is not None:
allowed_types_to_check = [] allowed_types_to_check = []
if myType.filter_content_types: 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) contentType = portal_types.getTypeInfo(portal_type)
if contentType is None: if contentType is None:
raise AttributeError, "Portal type '%s' does not exist " \ raise AttributeError, "Portal type '%s' does not exist " \
......
...@@ -1244,15 +1244,15 @@ class TestConstraint(PropertySheetTestCase): ...@@ -1244,15 +1244,15 @@ class TestConstraint(PropertySheetTestCase):
# this property suppose that we can add some Organisation inside # this property suppose that we can add some Organisation inside
# Organisation, so we temporary patch the type information. # Organisation, so we temporary patch the type information.
ti = self.getTypesTool().getTypeInfo(obj) ti = self.getTypesTool().getTypeInfo(obj)
allowed_types = list(ti.allowed_content_types) allowed_types = ti.getTypeAllowedContentTypeList()
ti.allowed_content_types = allowed_types + ['Organisation'] ti._setTypeAllowedContentTypeList(allowed_types + ['Organisation'])
try: try:
constraint.fixConsistency(obj) constraint.fixConsistency(obj)
self.assertEquals('foo', obj.getDefaultOrganisationTitle()) self.assertEquals('foo', obj.getDefaultOrganisationTitle())
self.assertEquals('foo', obj.default_organisation.getTitle()) self.assertEquals('foo', obj.default_organisation.getTitle())
finally: finally:
ti.allowed_content_types = tuple(allowed_types) ti._setTypeAllowedContentTypeList(allowed_types)
def test_PropertyTypeValidityFixLocalPropertiesForCategories(self): def test_PropertyTypeValidityFixLocalPropertiesForCategories(self):
"""Tests PropertyTypeValidity can repairs categories when this property """Tests PropertyTypeValidity can repairs categories when this property
is added on the class later. is added on the class later.
......
...@@ -2449,10 +2449,10 @@ class TestPropertySheet: ...@@ -2449,10 +2449,10 @@ class TestPropertySheet:
'Test Add Permission Document') 'Test Add Permission Document')
# allow this type info in Person Module # allow this type info in Person Module
container_type_info = self.portal.portal_types.getTypeInfo('Person Module') container_type_info = self.getTypesTool().getTypeInfo('Person Module')
container_type_info.allowed_content_types = tuple( container_type_info._setTypeAllowedContentTypeList(
container_type_info.allowed_content_types) + ( container_type_info.getTypeAllowedContentTypeList()
'Test Add Permission Document', ) + ['Test Add Permission Document'])
# by default this is empty, which implictly means "Add portal content", # by default this is empty, which implictly means "Add portal content",
# the default permission # the default permission
......
...@@ -123,25 +123,17 @@ class TestFolder(ERP5TypeTestCase, LogInterceptor): ...@@ -123,25 +123,17 @@ class TestFolder(ERP5TypeTestCase, LogInterceptor):
obj = self.newContent() obj = self.newContent()
self.assertEquals(obj.getId(), id_generator_id_list[expected_length]) 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.""" """Set allowed content types for Folder portal type."""
folder_ti = self.getTypesTool()['Folder'] self.getTypesTool().Folder.edit(
folder_ti.allowed_content_types = allowed_content_types type_allowed_content_type_list=allowed_content_type_list,
folder_ti.filter_content_types = True type_filter_content_type=True)
def _assertAllowedContentTypes(self, obj, expected_allowed_content_types): def _assertAllowedContentTypes(self, obj, expected_allowed_content_types):
"""Asserts that allowed content types for obj are exactly what we """Asserts that allowed content types for obj are exactly what we
have in expected_allowed_content_types.""" have in expected_allowed_content_types."""
allowed_content_types_id_list = [x.getId() for self.assertEqual(sorted(expected_allowed_content_types),
x in obj.allowedContentTypes()] sorted(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)
def test_AllowedContentTypes(self): def test_AllowedContentTypes(self):
type_list = ['Folder', 'Category', 'Base Category'] type_list = ['Folder', 'Category', 'Base Category']
......
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