unicode value
Michael Ströder
michael at stroeder.com
Thu May 24 09:15:29 CEST 2007
Alain Spineux wrote:
> On 5/23/07, Michael Ströder <michael at stroeder.com> wrote:
>>
>> https://sourceforge.net/tracker/?func=detail&atid=352072&aid=616567&group_id=2072
>
> - First, encode data when sending request to ldap server.
> Do you know an drawback to encode any unicode sting into utf-8 ?
Did you read my comment in the tracker item above? I repeat it here:
"One cannot always assume UTF-8 encoded Unicode strings in
attribute values. Think of attributes jpegPhoto,
userCertificate, etc. Therefore there's no generic way to
handle that at the API level without knowledge about the
syntax defined in the LDAP schema.
(Note that this has been debated to death on python-ldap-dev
mailing list.)"
> -Second, decode data coming back from the server.
> The only function to retrieve data is search(), right ?
Not necessarily. Think of LDAP extended operations, like whoami_s().
> what about the use of this kind of request ?
> ldap_con.search_s(base_dn, ldap.SCOPE_BASE, filter, ['cn', 'mail',
> u'givenName', u'sn' ])
>
> that way, python-lib know that attribute givenName and sn should be
> decoded into unicode string.
This will be cumbersome. You will have to pass these attributes into
method result() which in general has no knowledge about a particular
request it's receiving results for. And I'll keep it like this because I
still have the idea for implementing a connection pool with less thread
locking. Also it's not only a question of Unicode or not.
It's very simple to implement a small wrapper class sufficient for
simple applications. But I'm against doing this in the general
python-ldap API.
Ciao, Michael.
More information about the python-ldap
mailing list