From e071f5e107b2593f84812a02750a29cbca49ec22 Mon Sep 17 00:00:00 2001
From: Kazuhiko Shiozaki <kazuhiko@nexedi.com>
Date: Fri, 30 Mar 2007 08:12:22 +0000
Subject: [PATCH] support calling with getSelectionNames() for backward
 compatibility.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@13811 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Form/SelectionTool.py           | 11 ++++++++++-
 product/ERP5Form/tests/testSelectionTool.py |  4 ++++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/product/ERP5Form/SelectionTool.py b/product/ERP5Form/SelectionTool.py
index 1ce5a92769..b15a10d7c8 100644
--- a/product/ERP5Form/SelectionTool.py
+++ b/product/ERP5Form/SelectionTool.py
@@ -114,7 +114,8 @@ class SelectionTool( UniqueObject, SimpleItem ):
         del REQUEST.form['report_depth']
 
       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]
       form_id = dialog_id or REQUEST.get('dialog_id', None) or form_id or REQUEST.get('form_id', 'view')
       return getattr(context, form_id)()
@@ -132,6 +133,14 @@ class SelectionTool( UniqueObject, SimpleItem ):
         return [x.replace(prefix, '', 1) for x in self.getSelectionContainer().keys() if x.startswith(prefix)]
       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')
     def callSelectionFor(self, selection_name, context=None, REQUEST=None):
       if context is None: context = self
diff --git a/product/ERP5Form/tests/testSelectionTool.py b/product/ERP5Form/tests/testSelectionTool.py
index 8294a637d5..b413b97e4b 100644
--- a/product/ERP5Form/tests/testSelectionTool.py
+++ b/product/ERP5Form/tests/testSelectionTool.py
@@ -68,7 +68,11 @@ class TestSelectionTool(ERP5TypeTestCase):
       from Products.ERP5Form.SelectionTool import SelectionError
       self.assertRaises(SelectionError,
                         self.portal_selections.getSelectionNameList)
+      self.assertRaises(SelectionError,
+                        self.portal_selections.getSelectionNames)
     else:
+      self.assertEquals(['test_selection'],
+                        self.portal_selections.getSelectionNames())
       self.assertEquals(['test_selection'],
                         self.portal_selections.getSelectionNameList())
 
-- 
2.30.9