Commit e071f5e1 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

support calling with getSelectionNames() for backward compatibility.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@13811 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e5020fab
...@@ -114,7 +114,8 @@ class SelectionTool( UniqueObject, SimpleItem ): ...@@ -114,7 +114,8 @@ class SelectionTool( UniqueObject, SimpleItem ):
del REQUEST.form['report_depth'] del REQUEST.form['report_depth']
if query_string is not None: if query_string is not None:
LOG('SelectionTool', 0, 'DEPRECATED: _redirectToOriginalForm got called with a query_string. The variables must be passed in REQUEST.form.') warnings.warn('DEPRECATED: _redirectToOriginalForm got called with a query_string. The variables must be passed in REQUEST.form.',
DeprecationWarning)
context = REQUEST['PARENTS'][0] context = REQUEST['PARENTS'][0]
form_id = dialog_id or REQUEST.get('dialog_id', None) or form_id or REQUEST.get('form_id', 'view') form_id = dialog_id or REQUEST.get('dialog_id', None) or form_id or REQUEST.get('form_id', 'view')
return getattr(context, form_id)() return getattr(context, form_id)()
...@@ -132,6 +133,14 @@ class SelectionTool( UniqueObject, SimpleItem ): ...@@ -132,6 +133,14 @@ class SelectionTool( UniqueObject, SimpleItem ):
return [x.replace(prefix, '', 1) for x in self.getSelectionContainer().keys() if x.startswith(prefix)] return [x.replace(prefix, '', 1) for x in self.getSelectionContainer().keys() if x.startswith(prefix)]
return [] return []
# backward compatibility
security.declareProtected(ERP5Permissions.View, 'getSelectionNames')
def getSelectionNames(self, context=None, REQUEST=None):
warnings.warn("getSelectionNames() is deprecated.\n"
"Please use getSelectionNameList() instead.",
DeprecationWarning)
return self.getSelectionNameList(context, REQUEST)
security.declareProtected(ERP5Permissions.View, 'callSelectionFor') security.declareProtected(ERP5Permissions.View, 'callSelectionFor')
def callSelectionFor(self, selection_name, context=None, REQUEST=None): def callSelectionFor(self, selection_name, context=None, REQUEST=None):
if context is None: context = self if context is None: context = self
......
...@@ -68,7 +68,11 @@ class TestSelectionTool(ERP5TypeTestCase): ...@@ -68,7 +68,11 @@ class TestSelectionTool(ERP5TypeTestCase):
from Products.ERP5Form.SelectionTool import SelectionError from Products.ERP5Form.SelectionTool import SelectionError
self.assertRaises(SelectionError, self.assertRaises(SelectionError,
self.portal_selections.getSelectionNameList) self.portal_selections.getSelectionNameList)
self.assertRaises(SelectionError,
self.portal_selections.getSelectionNames)
else: else:
self.assertEquals(['test_selection'],
self.portal_selections.getSelectionNames())
self.assertEquals(['test_selection'], self.assertEquals(['test_selection'],
self.portal_selections.getSelectionNameList()) self.portal_selections.getSelectionNameList())
......
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