LDAP/LDIF Parsing
Bruno Desthuilliers
bdesth.quelquechose at free.quelquepart.fr
Sat Feb 3 12:23:52 EST 2007
Hallvard B Furuseth a écrit :
> Bruno Desthuilliers writes:
>
>>Hallvard B Furuseth a écrit :
>>
>>>> else:
>>>> # all LDAP attribs are multivalued by default,
>>>> # even when the schema says they are monovalued
>>>> if len(data) == 1:
>>>> return data[0]
>>>> else:
>>>> return data[:]
>>>
>>>IMHO, this just complicates the client code since the client needs to
>>>inserts checks of isinstance(return value, list) all over the place.
>>>Better to have a separate method which extracts just the first value of
>>>an attribute, if you want that.
>>
>>Most of the times, in a situation such as the one described by the OP,
>>one knows by advance if a given LDAP attribute will be used as
>>monovalued or multivalued. Well, this is at least my own experience...
>
> But if the attribute is multivalued, you don't know if it will contain
> just one value or not.
If you know which attributes are supposed to be multivalued in your
specific application, then it's time to write a more serious,
application-specific wrapper.
More information about the Python-list
mailing list