Commit 0f78c0f3 authored by Sebastien Robin's avatar Sebastien Robin

store the result of _getSortedPreferenceList in a transactional

variable

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@38131 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 19c8a446
......@@ -41,6 +41,7 @@ from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5Type.Cache import CachingMethod
from Products.ERP5Type.Utils import convertToUpperCase
from Products.ERP5Type.Accessor.TypeDefinition import list_types
from Products.ERP5Type.TransactionalVariable import getTransactionalVariable
from Products.ERP5Form import _dtmldir
_marker = object()
......@@ -225,6 +226,9 @@ class PreferenceTool(BaseTool):
""" return the most appropriate preferences objects,
sorted so that the first in the list should be applied first
"""
tv = getTransactionalVariable(self)
tv_key = 'PreferenceTool._getSortedPreferenceList/%s' % sql_catalog_id
if tv.get(tv_key, None) is None:
prefs = []
# XXX will also cause problems with Manager (too long)
# XXX For manager, create a manager specific preference
......@@ -247,7 +251,12 @@ class PreferenceTool(BaseTool):
sys_prefs = [x.getObject() for x in self.searchFolder(portal_type='System Preference', sql_catalog_id=sql_catalog_id) \
if x.getObject().getProperty('preference_state', 'broken') in ('enabled', 'global')]
sys_prefs.sort(key=lambda x: x.getPriority(), reverse=True)
return sys_prefs + prefs
preference_list = sys_prefs + prefs
tv[tv_key] = [x.getRelativeUrl() for x in preference_list]
else:
portal = self.getPortalObject()
preference_list = [portal.restrictedTraverse(x) for x in tv[tv_key]]
return preference_list
def _getActivePreferenceByPortalType(self, portal_type):
enabled_prefs = self._getSortedPreferenceList()
......
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