Commit a41f5c7e authored by Julien Muchembled's avatar Julien Muchembled

Fix performance issues when updating local roles on an object

* Implement ERP5TypeInformation.allowType because TypeInformation.allowType
  from CMF is very slow.
* Using objectValues(meta_type=...) instead of objectValues(portal_type=...)
  speeds up a little.

git-svn-id: https://svn.erp5.org/repos/public/erp5/sandbox/portal_types@29283 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b172c130
......@@ -4613,7 +4613,6 @@ Business Template is a set of definitions, such as skins, portal types and categ
, 'allowed_content_types': (
)
, 'filter_content_types' : 1
, 'global_allow' : 1
}
# This is a global variable
......
......@@ -13,10 +13,6 @@
<key> <string>acquire_local_roles</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>allow_discussion</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>content_meta_type</string> </key>
<value> <string>ERP5 Action Information</string> </value>
......@@ -33,10 +29,6 @@
<key> <string>filter_content_types</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>global_allow</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Action Information</string> </value>
......@@ -61,10 +53,6 @@
<key> <string>portal_type</string> </key>
<value> <string>Base Type</string> </value>
</item>
<item>
<key> <string>product</string> </key>
<value> <string>ERP5Type</string> </value>
</item>
</dictionary>
</pickle>
</record>
......
......@@ -75,11 +75,10 @@ class LocalRoleAssignorMixIn(object):
"""
if user_name is None:
# First try to guess from the owner
try:
user_name = ob.getOwnerInfo()['id']
except (AttributeError, TypeError):
pass
if user_name is None:
owner = ob.getOwnerTuple()
if owner:
user_name = owner[1]
else:
#FIXME We should check the type of the acl_users folder instead of
# checking which product is installed.
if ERP5UserManager is not None:
......@@ -150,7 +149,7 @@ class LocalRoleAssignorMixIn(object):
# Return also explicit local roles defined as subobjects of the document
if getattr(aq_base(ob), 'isPrincipiaFolderish', 0) and \
self.allowType('Role Definition'):
for role in ob.objectValues(portal_type='Role Definition'):
for role in ob.objectValues(meta_type='ERP5 Role Definition'):
if role.getRoleName():
yield role
......@@ -158,7 +157,7 @@ class LocalRoleAssignorMixIn(object):
'getRoleInformationList')
def getRoleInformationList(self):
"""Return all Role Information objects stored on this portal type"""
return self.objectValues(portal_type='Role Information')
return self.objectValues(meta_type='ERP5 Role Information')
security.declareProtected(Permissions.View, 'updateRoleMapping')
def updateRoleMapping(self, REQUEST=None, form_id=''):
......@@ -310,6 +309,13 @@ class ERP5TypeInformation(XMLObject,
)
group_list = ()
security.declarePublic('allowType')
def allowType(self, contentType):
"""Test if objects of 'self' can contain objects of 'contentType'
"""
return (not self.getTypeFilterContentType()
or contentType in self.getTypeAllowedContentTypeList())
#
# Acquisition editing interface
#
......@@ -493,7 +499,7 @@ class ERP5TypeInformation(XMLObject,
'getActionInformationList')
def getActionInformationList(self):
"""Return all Action Information objects stored on this portal type"""
return self.objectValues(portal_type='Action Information')
return self.objectValues(meta_type='ERP5 Action Information')
def getIcon(self):
return self.getTypeIcon()
......
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