Commit 7af9e70b authored by Jérome Perrin's avatar Jérome Perrin

PreferenceTool.getPreference method now accepts a default parameter, for

consistency with other getters.



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@15695 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 9dcfeea6
......@@ -175,8 +175,10 @@ class PreferenceTool(BaseTool):
security.declareProtected(Permissions.View, "getPreference")
def getPreference(self, pref_name, default=None) :
""" get the preference on the most appopriate Preference object. """
return getattr(self, 'get%s' %
convertToUpperCase(pref_name))(default=default)
method = getattr(self, 'get%s' % convertToUpperCase(pref_name), None)
if method:
return method(default=default)
return default
security.declareProtected(Permissions.ModifyPortalContent, "setPreference")
def setPreference(self, pref_name, value) :
......
......@@ -206,6 +206,10 @@ class TestPreferences(ERP5TypeTestCase):
'preferred_accounting_transaction_simulation_state_list')),
list(group.getPreferredAccountingTransactionSimulationStateList()))
self.assertEquals('default', pref_tool.getPreference(
'this_does_not_exists', 'default'))
def test_GetAttr(self, quiet=quiet, run=run_all_tests) :
""" checks that preference methods can be called directly
on portal_preferences """
......
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