[python-ldap] Ldap connectors pool

Tarek Ziadé ziade.tarek at gmail.com
Wed Sep 14 23:27:02 CEST 2011

2011/9/14 Michael Ströder <michael at stroeder.com>:
> Tarek Ziadé wrote:
>> I've been working on a pool class for ldap connectors, we're using for
>> the Firefox Sync server.
>> [..]
>> Example of usage:
>>   cm = ConnectionManager('ldap://localhost')
>>   with cm.connection('bind', 'password') as conn:
>>       ... do something with conn...
> Hmm, so it provides a slighty different API?

The connection manager returns ldap objects actually,

The addition is that you get a context manager to get that ldap object
and it takes care of recycling it when you get out if the with block.

> I'd really prefer something which is a drop-in replacement for an LDAPObject
> class not limiting what can be done with the current API.

So right now we have:

1/ a connection pool (ConnectionManager in our case)

2/ ldap objects returned by the connection pool

#1 is a new thing, #2 does not introduce any change to the existing
api of the LDAP object, but adds the get_lifetime() API.

Another ldap object could be used there (you can provide your own,
it's an option) and the lifetime feature could be deactivated in that


> Ciao, Michael.

Tarek Ziadé | http://ziade.org

More information about the python-ldap mailing list