From a3ecc091c6b65e6d0dc6248d40f2f8dbdfd59fcf Mon Sep 17 00:00:00 2001
From: Julien Muchembled <jm@nexedi.com>
Date: Mon, 28 Sep 2009 17:34:19 +0000
Subject: [PATCH] Remove some calls to deprecated functions

git-svn-id: https://svn.erp5.org/repos/public/erp5/sandbox/portal_types@29266 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5/Document/BusinessTemplate.py  |  3 +-
 product/ERP5/Document/RoleDefinition.py    |  5 ++-
 product/ERP5/tests/testBusinessTemplate.py | 42 +++++++++-------------
 product/ERP5/tests/testERP5Interfaces.py   |  1 +
 product/ERP5Type/ERP5Type.py               |  3 +-
 5 files changed, 24 insertions(+), 30 deletions(-)

diff --git a/product/ERP5/Document/BusinessTemplate.py b/product/ERP5/Document/BusinessTemplate.py
index df0138a32a..2241f63b9f 100644
--- a/product/ERP5/Document/BusinessTemplate.py
+++ b/product/ERP5/Document/BusinessTemplate.py
@@ -2375,7 +2375,8 @@ class ActionTemplateItem(ObjectTemplateItem):
       obj = p.unrestrictedTraverse(url)
       is_new_action = obj.getParentId() == 'portal_types'
       id_id = is_new_action and 'reference' or 'id'
-      for action in obj.listActions():
+      for action in (is_new_action and obj.getActionInformationList
+                                    or obj.listActions)():
         if getattr(action, id_id) == value:
           break
       else:
diff --git a/product/ERP5/Document/RoleDefinition.py b/product/ERP5/Document/RoleDefinition.py
index 36db894599..1d7a3d1e12 100644
--- a/product/ERP5/Document/RoleDefinition.py
+++ b/product/ERP5/Document/RoleDefinition.py
@@ -25,9 +25,10 @@
 #
 ##############################################################################
 
+import zope.interface
 from AccessControl import ClassSecurityInfo
 from Products.CMFCore.utils import getToolByName
-from Products.ERP5Type import Permissions, PropertySheet, Constraint, interfaces
+from Products.ERP5Type import Permissions, PropertySheet, interfaces
 from Products.ERP5Type.XMLObject import XMLObject
 from Products.ERP5Type.ERP5Type \
   import ERP5TYPE_SECURITY_GROUP_ID_GENERATION_SCRIPT
@@ -44,6 +45,8 @@ class RoleDefinition(XMLObject):
     security = ClassSecurityInfo()
     security.declareObjectProtected(Permissions.AccessContentsInformation)
 
+    zope.interface.implements(interfaces.ILocalRoleGenerator)
+
     # Default Properties
     property_sheets = ( PropertySheet.Base
                       , PropertySheet.XMLObject
diff --git a/product/ERP5/tests/testBusinessTemplate.py b/product/ERP5/tests/testBusinessTemplate.py
index 022a503184..8b9a96bca8 100644
--- a/product/ERP5/tests/testBusinessTemplate.py
+++ b/product/ERP5/tests/testBusinessTemplate.py
@@ -1215,15 +1215,12 @@ class TestBusinessTemplate(ERP5TypeTestCase, LogInterceptor):
     pt = self.getTypeTool()
     object_id = sequence.get('object_ptype_id')
     object_pt = pt._getOb(object_id)
-    object_pt.addAction(
-      id = 'become_geek'
-      , name = 'Become Geek'
-      , action = 'become_geek_action'
-      , condition = ''
-      , permission = ('View', )
-      , category = 'object_action'
-      , visible = 1
-      , priority = 2.0 )
+    object_pt.newContent(portal_type='Action Information',
+                         reference='become_geek',
+                         title='Become Geek',
+                         action='become_geek_action',
+                         action_type='object_action',
+                         float_index=2.0)
     sequence.edit(first_action_id='become_geek')
 
   def stepCreateEmptyAction(self, sequence=None, sequence_list=None, **kw):
@@ -1233,14 +1230,10 @@ class TestBusinessTemplate(ERP5TypeTestCase, LogInterceptor):
     pt = self.getTypeTool()
     object_id = sequence.get('object_ptype_id')
     object_pt = pt._getOb(object_id)
-    object_pt.addAction(id = ''
-      , name = ' Nerd'
-      , action = ''
-      , condition = ''
-      , permission = ()
-      , category = ''
-      , visible = 1
-      , priority = 1.2)
+    object_pt.newContent(portal_type='Action Information',
+                         title='Name',
+                         action_permission_list=(),
+                         float_index=1.2)
 
   def stepCreateSecondAction(self, sequence=None, sequence_list=None, **kw):
     """
@@ -1249,15 +1242,12 @@ class TestBusinessTemplate(ERP5TypeTestCase, LogInterceptor):
     pt = self.getTypeTool()
     object_id = sequence.get('object_ptype_id')
     object_pt = pt._getOb(object_id)
-    object_pt.addAction(
-      id = 'become_nerd'
-      , name = 'Become Nerd'
-      , action = 'become_nerd_action'
-      , condition = ''
-      , permission = ('View', )
-      , category = 'object_action'
-      , visible = 1
-      , priority = 1.5 )
+    object_pt.newContent(portal_type='Action Information',
+                         reference='become_nerd',
+                         title='Become Nerd',
+                         action='become_nerd_action',
+                         action_type='object_action',
+                         float_index=1.5)
     sequence.edit(second_action_id='become_nerd')
 
   def stepCheckFirstActionExists(self, sequence=None, sequence_list=None, **kw):
diff --git a/product/ERP5/tests/testERP5Interfaces.py b/product/ERP5/tests/testERP5Interfaces.py
index 2f7c602db9..40f90be7db 100644
--- a/product/ERP5/tests/testERP5Interfaces.py
+++ b/product/ERP5/tests/testERP5Interfaces.py
@@ -44,6 +44,7 @@ implements_tuple_list = [
   ('BusinessPath', 'IBusinessPath'),
   ('BusinessPath', 'ICategoryAccessProvider'),
   ('DeliveryLine', 'IDivergenceSolver'),
+  ('RoleDefinition', 'ILocalRoleGenerator'),
   ('TradeCondition', 'ITransformation'),
   ('TradeModelCell', 'ITransformation'),
   ('TradeModelCell', 'IVariated'),
diff --git a/product/ERP5Type/ERP5Type.py b/product/ERP5Type/ERP5Type.py
index d7caf824a9..ba8c585b59 100644
--- a/product/ERP5Type/ERP5Type.py
+++ b/product/ERP5Type/ERP5Type.py
@@ -544,7 +544,6 @@ class ERP5TypeInformation(XMLObject,
     security.declareProtected(Permissions.ModifyPortalContent, 'deleteActions')
     @deprecated
     def deleteActions(self, selections=(), REQUEST=None):
-      # XXX Should be deprecated.
       action_list = self.listActions()
       self.manage_delObjects([action_list[x].id for x in selections])
 
@@ -553,7 +552,7 @@ class ERP5TypeInformation(XMLObject,
     def listActions(self, info=None, object=None):
       """ List all the actions defined by a provider."""
       return sorted(self.getActionInformationList(),
-                    key=lambda x: x.getFloatIndex())
+                    key=lambda x: (x.getFloatIndex(), x.getId()))
 
     def _importOldAction(self, old_action):
       from Products.ERP5Type.Document.ActionInformation import ActionInformation
-- 
2.30.9