From 66c38dcb9bf635abb0a08e307ed9740276b97c31 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Wed, 12 Sep 2007 08:39:03 +0000
Subject: [PATCH] user_name= was just passed to make the cache vary, instead
 generate a cache key containing user name, so that user_name parameter is not
 mixed with standard parameters. Don't pass positional arguments to
 searchFolder, because it does not support any.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@16280 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Form/PreferenceTool.py | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/product/ERP5Form/PreferenceTool.py b/product/ERP5Form/PreferenceTool.py
index b2ef2e4ee0..eb692196b9 100644
--- a/product/ERP5Form/PreferenceTool.py
+++ b/product/ERP5Form/PreferenceTool.py
@@ -124,7 +124,7 @@ class PreferenceMethod(Method):
     self._null = (None, '', (), [])
 
   def __call__(self, instance, *args, **kw):
-    def _getPreference(user_name=None, *args, **kw):
+    def _getPreference(*args, **kw):
       value = None
       for pref in instance._getSortedPreferenceList(*args, **kw):
         value = getattr(pref, self._preference_name, _marker)
@@ -136,10 +136,10 @@ class PreferenceMethod(Method):
             break
       return value
     _getPreference = CachingMethod(_getPreference,
-            id=self._preference_cache_id,
+            id='%s.%s' % (self._preference_cache_id,
+                          getSecurityManager().getUser().getId()),
             cache_factory='erp5_ui_short')
-    user_name = getSecurityManager().getUser().getId()
-    value = _getPreference(user_name=user_name, *args, **kw)
+    value = _getPreference(*args, **kw)
     # XXX Preference Tool has a strange assumption that, even if
     # all values are null values, one of them must be returned.
     # Therefore, return a default value, only if explicitly specified,
@@ -210,7 +210,7 @@ class PreferenceTool(BaseTool):
     #                  or better solution
     user = getToolByName(self, 'portal_membership').getAuthenticatedMember()
     user_is_manager = 'Manager' in user.getRolesInContext(self)
-    for pref in self.searchFolder(portal_type='Preference', *args, **kw) :
+    for pref in self.searchFolder(portal_type='Preference', **kw) :
       pref = pref.getObject()
       if pref is not None and pref.getProperty('preference_state',
                                 'broken') in ('enabled', 'global'):
-- 
2.30.9