|
From: Jacek K. <ja...@bn...> - 2001-11-12 20:21:21
|
Hi,
I have just commited ldap.set_option() function and ldap.OPT_* constants.
It is not perfect yet (probably boolean options don't work as they
should), but it can already be used for TLS certificate validation
setup.
You can try this:
ldap.set_option(ldap.OPT_DEBUG_LEVEL,255)
ldap.set_option(ldap.OPT_X_TLS,ldap.OPT_X_TLS_HARD)
ldap.set_option(ldap.OPT_X_TLS_CACERTFILE,"cacerts.pem")
ldap.set_option(ldap.OPT_X_TLS_REQUIRE_CERT,1)
l=ldap.initialize("ldaps://some.ldap.host")
l.simple_bind_s("","")
I will also make ldap.get_option() function and get_option/set_option
methods of LDAPObject.
Greets,
Jacek
|
|
From: Michael <mi...@st...> - 2001-11-12 23:26:20
|
Jacek Konieczny wrote: > > I will also make ldap.get_option() function and get_option/set_option > methods of LDAPObject. Shouldn't the LDAPObject-related options be implemented by __getattr__() and __setattr__()? I have no personal preference but this is how it's done today (e.g. "version" etc.) and it's very Pythonic. Ciao, Michael. |
|
From: David L. <dav...@it...> - 2001-11-13 03:01:17
|
On Tue, 13 Nov 2001, Michael Str=F6der typed thusly: > Jacek Konieczny wrote: > > > > I will also make ldap.get_option() function and get_option/set_option > > methods of LDAPObject. > > Shouldn't the LDAPObject-related options be implemented by > __getattr__() and __setattr__()? I have no personal preference but > this is how it's done today (e.g. "version" etc.) and it's very > Pythonic. you mean, like this? =09print ldap.option.api_info =09ldap.option.debug_level =3D 2 i think it is just as easy doing it the current get_option() way, and means that OpenLDAP's documentation/manuals remains sensible for people who want to read up on what the options mean. The only real plus I can think of with attributes is that you have the advantage of hasattr() and as you say, it is more pythonic. d --=20 David Leonard Dav...@it... Dept of Inf. Tech. and Elec. Engg _ Ph:+61 404 844 850 The University of Queensland |+| http://www.itee.uq.edu.au/~leonard/ QLD 4072 AUSTRALIA ~` '~ B73CD65FBEF4C089B79A8EBADF1A932F13E= A0FC8 |
|
From: Michael <mi...@st...> - 2001-11-13 09:54:57
|
David Leonard wrote: > > On Tue, 13 Nov 2001, Michael Ströder typed thusly: > > > Jacek Konieczny wrote: > > > > > > I will also make ldap.get_option() function and get_option/set_option > > > methods of LDAPObject. > > > > Shouldn't the LDAPObject-related options be implemented by > > __getattr__() and __setattr__()? I have no personal preference but > > this is how it's done today (e.g. "version" etc.) and it's very > > Pythonic. > > you mean, like this? > > print ldap.option.api_info > > ldap.option.debug_level = 2 > > i think it is just as easy doing it the current get_option() way, > and means that OpenLDAP's documentation/manuals remains sensible for > people who want to read up on what the options mean. > > The only real plus I can think of with attributes is that you have the > advantage of hasattr() and as you say, it is more pythonic. As I said, I have no personal preference. We can keep get_option() to be more compliant with OpenLDAP's LDAP-EXT API. I can do the Pythonic way in a Python wrapper module above if needed some time. Ciao, Michael. |
|
From: Jacek K. <ja...@bn...> - 2001-11-13 12:08:36
|
On Tue, Nov 13, 2001 at 12:25:57AM +0100, Michael Str=F6der wrote:
> Jacek Konieczny wrote:
> >=20
> > I will also make ldap.get_option() function and get_option/set_option
> > methods of LDAPObject.
>=20
> Shouldn't the LDAPObject-related options be implemented by
> __getattr__() and __setattr__()? I have no personal preference but
> this is how it's done today (e.g. "version" etc.) and it's very
> Pythonic.
LDAP API includes ldap_set_option() function. Anybody who knows this API
will search for something similar in python-ldap. The same function is
used to set some global/default options and to set connection-specific
options. It would be quite strange to treat them differently.
I agree, that __getattr__() and __setattr__() are more Pythonic, so I
think it should stay for at least some options. The two interfaces can
coexist. In fact __setattr__() will call set_option() internally, after
translating attribute name to LDAP_OPT_* constant.
Greets,
Jacek
|
|
From: David L. <dav...@it...> - 2001-11-13 12:15:22
|
On Tue, 13 Nov 2001, Jacek Konieczny typed thusly: > The two interfaces can coexist. um, i'd like to avoid too many ways of doing the same thing.. it leads to confusion... so, just one way or the other thanks :) d -- David Leonard Dav...@it... Dept of Inf. Tech. and Elec. Engg _ Ph:+61 404 844 850 The University of Queensland |+| http://www.itee.uq.edu.au/~leonard/ QLD 4072 AUSTRALIA ~` '~ B73CD65FBEF4C089B79A8EBADF1A932F13EA0FC8 |
|
From: Jacek K. <ja...@bn...> - 2001-11-13 12:30:43
|
On Tue, Nov 13, 2001 at 10:13:54PM +1000, David Leonard wrote:
> On Tue, 13 Nov 2001, Jacek Konieczny typed thusly:
>
> > The two interfaces can coexist.
>
> um, i'd like to avoid too many ways of doing the same thing.. it leads to
> confusion... so, just one way or the other thanks :)
In this case IMHO set_option() seems more reasonable. But it will break
backward compatibility (for those options which are already implemented
as attributes).
Using attributes of LDAPObject for connection-specific options and
set_object() function for global/default options will make mess like
this:
import ldap
ldap.set_option(ldap.OPT_SIZELIMIT,100) # sets default size limit
l=ldap.initialize("ldap://localhost/")
l.sizelimit=100 # sets size limit for connection l
As you see the same option is set in two totally different ways. I the
C API both are set using the same function with only difference is that,
in the first case first argument (LDAP object) is NULL.
I won't touch __setattr__() and set_option() of LDAPObject until we
decide on some solution.
I personally still think that the two (attribute, set_option()) solution
can coexist, provided they share as much code as possible.
Greets,
Jacek
|
|
From: Michael <mi...@st...> - 2001-11-13 13:28:26
|
Jacek Konieczny wrote: > > On Tue, Nov 13, 2001 at 10:13:54PM +1000, David Leonard wrote: > > On Tue, 13 Nov 2001, Jacek Konieczny typed thusly: > > > > > The two interfaces can coexist. > > > > um, i'd like to avoid too many ways of doing the same thing.. it leads to > > confusion... so, just one way or the other thanks :) > > In this case IMHO set_option() seems more reasonable. Go for it. > But it will break > backward compatibility (for those options which are already implemented > as attributes). Backward compability to python-ldap with OpenLDAP 1 libs regarding options was broken with OpenLDAP 2 patches anyway. I don't mind. > I won't touch __setattr__() and set_option() of LDAPObject until we > decide on some solution. Go for set_option() since the C module part should map OpenLDAP 2 API more or less directly. Ciao, Michael. |
|
From: Joe L. <jl...@ee...> - 2001-11-13 18:51:25
|
I just wanted to butt in with my opinion here. It seems that to date, the python-ldap API has mirrored that of the=20 c-API, but also provided an LDAP object wrapper. I think is correct as well as ideal for us to support both the=20 set_option() method in the direct API, but for object-oriented purposes=20= provide an internal mechanism that calls the set_option using set_attr=20= and get_attr syntax. Those who will use the LDAPObject and similar=20 mentality will appreciate the latter, and I feel it doesn't confuse=20 things if those methods are documented as object methods. On Tuesday, November 13, 2001, at 05:01 AM, Michael Str=F6der wrote: > Jacek Konieczny wrote: >> >> On Tue, Nov 13, 2001 at 10:13:54PM +1000, David Leonard wrote: >>> On Tue, 13 Nov 2001, Jacek Konieczny typed thusly: >>> >>>> The two interfaces can coexist. >>> >>> um, i'd like to avoid too many ways of doing the same thing.. it=20 >>> leads to >>> confusion... so, just one way or the other thanks :) >> >> In this case IMHO set_option() seems more reasonable. > > Go for it. > >> But it will break >> backward compatibility (for those options which are already = implemented >> as attributes). > > Backward compability to python-ldap with OpenLDAP 1 libs regarding > options was broken with OpenLDAP 2 patches anyway. I don't mind. > >> I won't touch __setattr__() and set_option() of LDAPObject until we >> decide on some solution. > > Go for set_option() since the C module part should map OpenLDAP 2 > API more or less directly. > > Ciao, Michael. > > _______________________________________________ > Python-LDAP-dev mailing list > Pyt...@li... > https://lists.sourceforge.net/lists/listinfo/python-ldap-dev > |
|
From: Michael <mi...@st...> - 2001-11-14 00:00:17
|
Joe Little wrote: > > It seems that to date, the python-ldap API has mirrored that of the > c-API, but also provided an LDAP object wrapper. > > I think is correct as well as ideal for us to support both the > set_option() method in the direct API, but for object-oriented purposes > provide an internal mechanism that calls the set_option using set_attr > and get_attr syntax. Since experience of the last months shows that most people on this list don't like to muck out old C code I'd prefer to keep it as lean as possible. It's trivial to write a Python object wrapper around it which maps set_option() to __setattr__(). Ciao, Michael. |