[python-ldap] syncrepl fix for pyasn1 >= 0.3
Michael Ströder
michael at stroeder.com
Sat Nov 11 16:03:46 EST 2017
Ilya Etingof wrote:
> On 11 Nov 2017, at 20:56, Michael Ströder <michael at stroeder.com> wrote:
>> 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')
>
> I might be looking at the wrong patch:
>
> https://github.com/pyldap/pyldap/pull/126/files#diff-184de394f72e23df85150ec1679a77e2L126
>
> But there the instance attribute `attribute_type_error` is always set to either `None` or a value object.
Seems the back-port following patch sent to the list was incomplete.
Nevermind. I've corrected it.
>> 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.
>
> Makes sense! Let me come up with an implementation shortly.
Would be awesome. Looking forward to it.
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/ad1a8209/attachment-0001.bin>
More information about the python-ldap
mailing list