[python-ldap] syncrepl fix for pyasn1 >= 0.3
Michael Ströder
michael at stroeder.com
Sat Nov 11 14:56:05 EST 2017
Michael Ströder wrote:
> All people installing/upgrading
> from PyPI would be happy with python-ldap 2.5.x and pyasn1 0.3.x.
I've decided to start 2.5.0 incorporating this patch without the
backward-compability expressions. But I have some doubts.
For example in class SSSResponseControl I now see this code:
attribute_type_error = p.getComponentByName('attributeType')
if attribute_type_error.hasValue():
self.attribute_type_error = attribute_type_error
This does not set class attribute attribute_type_error at all in case
there was no error. So this also changes the API for the calling
application because instead of checking for
foo_sss.attribute_type_error is None
it has to check for
hasattr(foo_sss, 'attribute_type_error')
Hmm, I could implement a custom ResponseControl.__getattr__() which
returns None in case of non-existent but known class attributes.
But frankly it would be more nice if pyasn1 method getComponentByName()
would take another optional parameter for default value returned in case
of .hasValue()==False.
So I could simply define a default value (here None)
p.getComponentByName('attributeType', None)
and be done with it. This would avoid a lot of if-statements with
.hasValue() and the ResponseControl.__getattr__() workaround.
Ciao, Michael.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3829 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://mail.python.org/pipermail/python-ldap/attachments/20171111/09689edb/attachment.bin>
More information about the python-ldap
mailing list