[python3-ldap] Feedback on aspects of python3-ldap's API

Florian Friesdorf flo at chaoflow.net
Tue Sep 23 12:31:55 CEST 2014


Hi Giovanni,

On Tue, Sep 23 2014, python3ldap wrote:
> Regarding the connection context manager there is no magic at all in
> it. As stated in the docs the connection retains the status it had
> before entering the context. This has been done because it's quite
> expensive to bind a connection each time you get in the context, so
> the connection is not destroyed when exiting it. Furthermore if you
> use "lazy" connections (that bind only if there is some real operation
> to perform) you gain a speed boost in long standing routines (I work
> mainly on identity management systems and this has proven useful).

    with Connection(...) as c:
        ...

I would expect the connection to be closed when the context is left,
compare to:

    with open('file') as f:
        ...

To change the state of binding as part of a context manager I would
expect something like:

    c = Connection(...)   # unbound
    with c.bind(...):
        ...

best regards
florian

> 2014-09-22 19:15 GMT+02:00 Florian Friesdorf <flo at chaoflow.net>:
>>
>> Hi Giovanni,
>>
>> On community.plone.org[1] you are asking what we consider confusing
>> about python3-ldap's API. I hope it is in your interest that I post this
>> feedback here to the python3-ldap list. To the other aspects of your
>> posting I will reply on community.plone.org
>>
>> [1] https://community.plone.org/t/ldap-status-quo-and-where-to-go-from-here/285
>>
>> On Sun, Sep 21 2014, cannata_g wrote:
>>> Hello everybody,
>>> I'm the author of python3-ldap. I read in your message that you think
>>> that the python3-ldap API is "confusing". I'd like to know what you
>>> mean by that, are you referring to the documentation (still not
>>> completed) or to the API itself?.
>>
>> The opinion that python3-ldap's API is confusing to us, was formed after
>> a brief look at the quick tour[2]:
>>
>> [2] http://pythonhosted.org/python3-ldap/quicktour.html
>>
>> To perform a search, python3-ldap uses a connection object on which a
>> search method is called with the search parameters. The result is not
>> returned but instead there are .result and .response attributes on the
>> connection.
>>
>> When using a connection as context-manager, the connection lives on
>> after leaving the context. Within the context the binding to the ldap
>> server is magically changed.
>>
>> Both these things we consider rather untypical for pythonic APIs.
>>
>> regards
>> Marko and Florian
>> --
>> 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
>>
>> _______________________________________________
>> python3-ldap mailing list
>> python3-ldap at python.org
>> https://mail.python.org/mailman/listinfo/python3-ldap
>>

-- 
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/python3-ldap/attachments/20140923/d4c85d46/attachment.sig>


More information about the python3-ldap mailing list