From 7f50f790d3e04bdc1ee7edcda523b86157f635b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com> Date: Tue, 14 Sep 2010 11:48:19 +0000 Subject: [PATCH] - include the username in the cache key, because user can change in one transaction - adjust tests after 38131 git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@38350 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5Form/PreferenceTool.py | 6 +++--- product/ERP5Form/tests/testPreferences.py | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/product/ERP5Form/PreferenceTool.py b/product/ERP5Form/PreferenceTool.py index 8fae31ee0d..fadf92fabf 100644 --- a/product/ERP5Form/PreferenceTool.py +++ b/product/ERP5Form/PreferenceTool.py @@ -227,13 +227,14 @@ class PreferenceTool(BaseTool): sorted so that the first in the list should be applied first """ tv = getTransactionalVariable(self) - tv_key = 'PreferenceTool._getSortedPreferenceList/%s' % sql_catalog_id + user = getToolByName(self, 'portal_membership').getAuthenticatedMember() + tv_key = 'PreferenceTool._getSortedPreferenceList/%s/%s' % (user, + 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 # 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', sql_catalog_id=sql_catalog_id): pref = pref.getObject() @@ -254,7 +255,6 @@ class PreferenceTool(BaseTool): preference_list = sys_prefs + prefs tv[tv_key] = preference_list else: - portal = self.getPortalObject() preference_list = tv[tv_key] return preference_list diff --git a/product/ERP5Form/tests/testPreferences.py b/product/ERP5Form/tests/testPreferences.py index 1bd361bbab..15bb84d0ce 100644 --- a/product/ERP5Form/tests/testPreferences.py +++ b/product/ERP5Form/tests/testPreferences.py @@ -104,6 +104,8 @@ class TestPreferences(PropertySheetTestCase): """ self.failUnless('Preference' in [x.getId() for x in self.getPortal().portal_preferences.allowedContentTypes()]) + self.failUnless('System Preference' in [x.getId() for x in + self.getPortal().portal_preferences.allowedContentTypes()]) def test_EnablePreferences(self): """ tests preference workflow """ @@ -119,6 +121,7 @@ class TestPreferences(PropertySheetTestCase): person1.portal_workflow.doActionFor( person1, 'enable_action', wf_id='preference_workflow') + transaction.commit() self.assertEquals(person1.getPreferenceState(), 'enabled') self.assertEqual( person1, self.getPreferenceTool().getActivePreference()) @@ -146,6 +149,7 @@ class TestPreferences(PropertySheetTestCase): portal_workflow.doActionFor( person2, 'enable_action', wf_id='preference_workflow') + transaction.commit() self.assertEqual(person2, self.getPreferenceTool().getActivePreference()) self.assertEqual(None, self.getPreferenceTool().getActiveSystemPreference()) @@ -214,6 +218,7 @@ class TestPreferences(PropertySheetTestCase): # disable person -> group is selected self.getWorkflowTool().doActionFor(person1, 'disable_action', wf_id='preference_workflow') + transaction.commit() self.assertEquals(list(pref_tool.getPreference( 'preferred_accounting_transaction_simulation_state_list')), list(group.getPreferredAccountingTransactionSimulationStateList())) -- 2.30.9