ReconnectLDAPObject doesn't reconnect after main failure

Michael Ströder michael at
Mon Jan 29 12:10:11 CET 2007

Alain Spineux wrote:
> Python is a language made to help and facilitate the developer work :
> - the developer dont need to test the result of any function, python
> (or the library) raise an exception if something is wrong.
> - the developer dont need to worry about the memory allocation, the
> garbage collector do it for him.
> - the developer dont need to close a file, the system do it for him
> when the object is released
> - the developer don't need to worry for long living LDAP connection,
> ReconnectLDAPObject  auto reconnect automatically for him :-)
> - python-ldap is also thread safe .....

Your list rather arguments for adding SimpleLDAPObject.__del__() if not
implemented yet (I have to look at it).

> Then why does the developer have to encapsulate any ldap statement into a
> try:
> except ldap.SERVER_DOWN,e:
>    SimpleLDAPObject.unbind_s(self)

Because in case of ldap.SERVER_DOWN the application might have some
means for fail-over, smart error handling or similar. python-ldap is
rather low-level. I expect application developers to wrap something
around SimpleLDAPObject which better suits there needs.

And I'd like to avoid breaking existing code. Calling unbind_s() twice
ldap.LDAPError: LDAP connection invalid

Do you have an overview how other database modules handle such cases?

Ciao, Michael.

More information about the python-ldap mailing list