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