From 103787e9a907efa51038a4751b546447f97d8212 Mon Sep 17 00:00:00 2001
From: Nicolas Delaby <nicolas@nexedi.com>
Date: Tue, 22 Feb 2011 15:41:20 +0000
Subject: [PATCH] Small optimization:  avoid looking up portal_object several
 times inside a loop

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@43564 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Form/MultiRelationField.py | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/product/ERP5Form/MultiRelationField.py b/product/ERP5Form/MultiRelationField.py
index 6d5f28d77f..24043f41e3 100644
--- a/product/ERP5Form/MultiRelationField.py
+++ b/product/ERP5Form/MultiRelationField.py
@@ -422,6 +422,7 @@ class MultiRelationEditor:
 
     def edit(self, o):
       if self.relation_editor_list is not None:
+        portal = o.getPortalObject()
 
         relation_object_list = []
         for value, uid, display_text, relation_key, item_key in \
@@ -434,11 +435,9 @@ class MultiRelationEditor:
               portal_module = None
               for p_item in self.portal_type_item:
                 if p_item[0] == portal_type:
-                  portal_module = o.getPortalObject().getDefaultModuleId(
-                                                            p_item[0])
+                  portal_module = portal.getDefaultModuleId(p_item[0])
               if portal_module is not None:
-                portal_module_object = getattr(o.getPortalObject(), 
-                                               portal_module)
+                portal_module_object = getattr(portal, portal_module)
                 kw ={}
                 kw[self.key] = value.replace('%', '')
                 kw['portal_type'] = portal_type
@@ -447,7 +446,7 @@ class MultiRelationEditor:
               else:
                 raise 
             else:
-              relation_object_list.append(o.portal_catalog.getObject(uid))
+              relation_object_list.append(portal.portal_catalog.getObject(uid))
 
         # Edit relation
         if self.relation_setter_id:
-- 
2.30.9