Commit 103787e9 authored by Nicolas Delaby's avatar Nicolas Delaby

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
parent 31c23c12
...@@ -422,6 +422,7 @@ class MultiRelationEditor: ...@@ -422,6 +422,7 @@ class MultiRelationEditor:
def edit(self, o): def edit(self, o):
if self.relation_editor_list is not None: if self.relation_editor_list is not None:
portal = o.getPortalObject()
relation_object_list = [] relation_object_list = []
for value, uid, display_text, relation_key, item_key in \ for value, uid, display_text, relation_key, item_key in \
...@@ -434,11 +435,9 @@ class MultiRelationEditor: ...@@ -434,11 +435,9 @@ class MultiRelationEditor:
portal_module = None portal_module = None
for p_item in self.portal_type_item: for p_item in self.portal_type_item:
if p_item[0] == portal_type: if p_item[0] == portal_type:
portal_module = o.getPortalObject().getDefaultModuleId( portal_module = portal.getDefaultModuleId(p_item[0])
p_item[0])
if portal_module is not None: if portal_module is not None:
portal_module_object = getattr(o.getPortalObject(), portal_module_object = getattr(portal, portal_module)
portal_module)
kw ={} kw ={}
kw[self.key] = value.replace('%', '') kw[self.key] = value.replace('%', '')
kw['portal_type'] = portal_type kw['portal_type'] = portal_type
...@@ -447,7 +446,7 @@ class MultiRelationEditor: ...@@ -447,7 +446,7 @@ class MultiRelationEditor:
else: else:
raise raise
else: else:
relation_object_list.append(o.portal_catalog.getObject(uid)) relation_object_list.append(portal.portal_catalog.getObject(uid))
# Edit relation # Edit relation
if self.relation_setter_id: if self.relation_setter_id:
......
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