[python-ldap] python-ldap improvements: attribute conversion

Florian Friesdorf flo at chaoflow.net
Thu Apr 21 22:58:21 CEST 2011

Dear Vitaliy, dear Michael,

@Vitaliy: just found your mail on python-ldap "LDAP attribute syntaxes to python
data types conversion" from November [1], which sadly received no answer,
but triggered my memory.

@Michael: you write in the todo to check the mailing list archives with
respect to unicode and attribute values - I was unable to find
something, it would be great if you could provide pointers.

I imported python-ldap to github [2] because I prefer it and intend to
work (maybe with Vitaliy?) on patches. I do not intend to create a fork
of python-ldap on pypi, highly value your work on python-ldap and want
to help. Apart from attribute conversion, I am interest in more
sophisticated reconnect management, which was also mentioned recently on
the mailing list. I also work on bda.ldap/node.ext.ldap and would rather
see corresponding functionality implemented properly in python-ldap or
some dedicated addon, instead of every higher level ldap library
reinventing the same cornered wheel.

For me it looks like the attribute conversions could be handled by
subclassing and overwriting _ldap_call [3], in pseudo-code:

def _ldap_call(self, func, *args, **kwargs):
    args = deep_utf8_copy(args)
    kwargs = deep_utf8_copy(kwargs)
    res = super(...)...
    if not self.convmap:
       return res
    return check_for_things_to_convert(res, self.convmap)

or more selectively in the affected methods.

Attribute conversion maps could be generated from automatically parsing
an ldap's schemas (if supported) or be provided by the user.

There are more details to be taken care of, Vitaliy gave this already
some thought in code contributed to higher level libraries. But before
putting more effort in here, I'd like to know whether we are fully of
track, or whether the general approach would be suitable for inclusion
into python-ldap.

[1] http://mail.python.org/pipermail/python-ldap/2010q4/002791.html
[2] https://github.com/chaoflow/python-ldap
[3] https://github.com/chaoflow/python-ldap/blob/master/Lib/ldap/ldapobject.py#L80

best regards
Florian Friesdorf <flo at chaoflow.net>
  GPG FPR: 7A13 5EEE 1421 9FC2 108D  BAAF 38F8 99A3 0C45 F083
Jabber/XMPP: flo at chaoflow.net
IRC: chaoflow on freenode,ircnet,blafasel,OFTC
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-ldap/attachments/20110421/887c576f/attachment.pgp>

More information about the python-ldap mailing list