Index: umc/python/udm/udm_ldap.py =================================================================== --- umc/python/udm/udm_ldap.py (Revision 40329) +++ umc/python/udm/udm_ldap.py (Arbeitskopie) @@ -1068,28 +1068,43 @@ def map_choices( obj_list ): result = [] for obj in obj_list: - obj.open() - + # first try it without obj.open() (expensive) + key = label = None if syn.key == 'dn': key = obj.dn - else: + if syn.label == 'dn': + label = obj.dn + if key is None: try: key = syn.key % obj.info except KeyError: - # ignore the entry as the key is important for a selection, there - # is no sensible fallback for the key (Bug #26994) - continue - if syn.label is None: - label = udm_objects.description( obj ) - elif syn.label == 'dn': - label = obj.dn - else: + # key is not yet in obj.info -> obj.open()! + pass + if label is None and syn.label is not None: try: label = syn.label % obj.info except KeyError: - # fallback to the default description as this is just what displayed - # to the user (Bug #26994) - label = udm_objects.description( obj ) + # key is not yet in obj.info -> obj.open()! + pass + if key is None or label is None: + obj.open() + if key is None: + try: + key = syn.key % obj.info + except KeyError: + # ignore the entry as the key is important for a selection, there + # is no sensible fallback for the key (Bug #26994) + continue + if label is None: + if syn.label is None: + label = udm_objects.description( obj ) + else: + try: + label = syn.label % obj.info + except KeyError: + # fallback to the default description as this is just what displayed + # to the user (Bug #26994) + label = udm_objects.description( obj ) result.append( (key, label) ) return result