|
1068 |
def map_choices( obj_list ): |
1068 |
def map_choices( obj_list ): |
1069 |
result = [] |
1069 |
result = [] |
1070 |
for obj in obj_list: |
1070 |
for obj in obj_list: |
1071 |
obj.open() |
1071 |
# first try it without obj.open() (expensive) |
1072 |
|
1072 |
key = label = None |
1073 |
if syn.key == 'dn': |
1073 |
if syn.key == 'dn': |
1074 |
key = obj.dn |
1074 |
key = obj.dn |
1075 |
else: |
1075 |
if syn.label == 'dn': |
|
|
1076 |
label = obj.dn |
1077 |
if key is None: |
1076 |
try: |
1078 |
try: |
1077 |
key = syn.key % obj.info |
1079 |
key = syn.key % obj.info |
1078 |
except KeyError: |
1080 |
except KeyError: |
1079 |
# ignore the entry as the key is important for a selection, there |
1081 |
# key is not yet in obj.info -> obj.open()! |
1080 |
# is no sensible fallback for the key (Bug #26994) |
1082 |
pass |
1081 |
continue |
1083 |
if label is None and syn.label is not None: |
1082 |
if syn.label is None: |
|
|
1083 |
label = udm_objects.description( obj ) |
1084 |
elif syn.label == 'dn': |
1085 |
label = obj.dn |
1086 |
else: |
1087 |
try: |
1084 |
try: |
1088 |
label = syn.label % obj.info |
1085 |
label = syn.label % obj.info |
1089 |
except KeyError: |
1086 |
except KeyError: |
1090 |
# fallback to the default description as this is just what displayed |
1087 |
# key is not yet in obj.info -> obj.open()! |
1091 |
# to the user (Bug #26994) |
1088 |
pass |
1092 |
label = udm_objects.description( obj ) |
1089 |
if key is None or label is None: |
|
|
1090 |
obj.open() |
1091 |
if key is None: |
1092 |
try: |
1093 |
key = syn.key % obj.info |
1094 |
except KeyError: |
1095 |
# ignore the entry as the key is important for a selection, there |
1096 |
# is no sensible fallback for the key (Bug #26994) |
1097 |
continue |
1098 |
if label is None: |
1099 |
if syn.label is None: |
1100 |
label = udm_objects.description( obj ) |
1101 |
else: |
1102 |
try: |
1103 |
label = syn.label % obj.info |
1104 |
except KeyError: |
1105 |
# fallback to the default description as this is just what displayed |
1106 |
# to the user (Bug #26994) |
1107 |
label = udm_objects.description( obj ) |
1093 |
|
1108 |
|
1094 |
result.append( (key, label) ) |
1109 |
result.append( (key, label) ) |
1095 |
return result |
1110 |
return result |