Commit 77a53809 authored by Jérome Perrin's avatar Jérome Perrin

fix undefined variables

parent 84029c01
...@@ -2781,12 +2781,10 @@ class ListBoxValidator(Validator.Validator): ...@@ -2781,12 +2781,10 @@ class ListBoxValidator(Validator.Validator):
for uid in listbox_uids: for uid in listbox_uids:
if uid[:4] == 'new_': if uid[:4] == 'new_':
if object_dict is None: if object_dict is None:
object_dict = {}
list_method = field.get_value('list_method') list_method = field.get_value('list_method')
list_method = getattr(here, list_method.method_name) list_method = getattr(here, list_method.method_name)
#LOG('ListBoxValidator', 0, 'call %s' % repr(list_method)) for obj in list_method(REQUEST=REQUEST, **params):
object_list = list_method(REQUEST=REQUEST, **params)
object_dict = dict()
for obj in object_list:
o_uid = obj.getUid() o_uid = obj.getUid()
assert o_uid not in object_dict,\ assert o_uid not in object_dict,\
"List method returned duplicate uid %s %s" % ( "List method returned duplicate uid %s %s" % (
...@@ -2822,20 +2820,17 @@ class ListBoxValidator(Validator.Validator): ...@@ -2822,20 +2820,17 @@ class ListBoxValidator(Validator.Validator):
# Here we generate again the object_list with listbox the listbox we # Here we generate again the object_list with listbox the listbox we
# have just created # have just created
# XXX why ? -jerome
if listbox: if listbox:
object_dict = {}
list_method = field.get_value('list_method') list_method = field.get_value('list_method')
list_method = getattr(here, list_method.method_name) list_method = getattr(here, list_method.method_name)
REQUEST.set(field.id, listbox) REQUEST.set(field.id, listbox)
object_list = list_method(REQUEST=REQUEST, **params) for obj in list_method(REQUEST=REQUEST, **params):
object_dict = dict()
for obj in object_list:
o_uid = obj.getUid() o_uid = obj.getUid()
assert o_uid not in object_dict,\ assert o_uid not in object_dict,\
"List method returned duplicate uid %s" % o_uid "List method returned duplicate uid %s" % o_uid
object_dict[o_uid] = obj object_dict[o_uid] = obj
for uid in listbox_uids: for uid in listbox_uids:
row_result = {} row_result = {}
if uid[:4] == 'new_': if uid[:4] == 'new_':
...@@ -2878,19 +2873,20 @@ class ListBoxValidator(Validator.Validator): ...@@ -2878,19 +2873,20 @@ class ListBoxValidator(Validator.Validator):
except (KeyError, NotFound, ValueError), err: except (KeyError, NotFound, ValueError), err:
# It is possible that this object is not catalogged yet. So # It is possible that this object is not catalogged yet. So
# the object must be obtained from ZODB. # the object must be obtained from ZODB.
if object_list is None: if object_dict is None:
object_dict = {}
list_method = field.get_value('list_method') list_method = field.get_value('list_method')
list_method = getattr(here, list_method.method_name) list_method = getattr(here, list_method.method_name)
object_list = list_method(REQUEST=REQUEST, **params) for obj in list_method(REQUEST=REQUEST, **params):
for o in object_list: o_uid = str(obj.getUid())
try: assert o_uid not in object_dict,\
if o.getUid() == int(uid): "List method returned duplicate uid %s" % o_uid
break object_dict[o_uid] = obj
except ValueError:
if str(o.getUid()) == uid: o = object_dict.get(str(uid))
break if o is None:
else:
raise err raise err
row_key = o.getUrl() row_key = o.getUrl()
for sql in editable_column_ids: for sql in editable_column_ids:
editable_field = editable_field_dict.get(sql.replace('.', '_')) editable_field = editable_field_dict.get(sql.replace('.', '_'))
......
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