Python parts of module ldap

Jeffrey C. Ollie jeff at ollie.clive.ia.us
Sat Dec 15 23:24:07 CET 2001


On Sat, Dec 15, 2001 at 09:31:25PM +0100, Michael Ströder wrote:
> Jacek Konieczny wrote:
> > 
> > On Sat, Dec 15, 2001 at 09:03:44PM +0100, Michael Ströder wrote:
> > > After checking in some of my modules below Lib/ldap/ I noticed a
> > > serious drawback:
> > > All modules are dependent on availability of OpenLDAP 2 libs if
> > > located under Lib/ldap/ because of the "from _ldap import *" done in
> > > Lib/ldap/__init__.py.
> > >
> > [...]
> > >
> > > Any opinions?
> > 
> > Maybe you could put "from _ldap import *" in some "try:/except:" block.
> 
> I already thought of that. But this makes error reports about
> importing problems somewhat harder. E.g. if linking of shared libs
> fails it's much more useful to have the original traceback instead
> of e.g. a NameError exception afterwards. That's not good style.

What about something like:

import sys
_ldap_import_exception = (None, None, None)
try:
    from _ldap import *
except ImportError:
    _ldap_import_exception = sys.exc_info()

Jeff





More information about the python-ldap mailing list