Default value lost in binding.Obtain()

Alexey Smishlayev <[email protected]> Tue, 29 Sep 2015 16:03:26 +0300
Newsgroups gmane.comp.python.peak
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--------------080708010904010300000007
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit

Hello!

Today, fiddling with the binding.Obtain() I noticed that the default 
value gets lost.

In my application, I have a component tree and I want an attribute to be 
defined in any component in that tree, so I created binding:

 >     callback = binding.Obtain("callbackFunction", default=lambda arg: 
None)
 >

So, in case that no component defines a callbackFunction, the lambda 
function would be used as a fallback.
Unfortunately, "default" option is ignored unless target name contains 
slashes (e.g. "/callbackFunction", "./callBackFunction", 
"../callbackFunction")

I went to the peak/binding/components.py trying to fix it and propose 
the attached patch.
The problem is that default value was not propagated to the 
acquireComponent() call, so an exception occurred.


Best regards,
Alexey Smishlayev

--------------080708010904010300000007
Content-Type: text/plain; charset=UTF-8; x-mac-type="0"; x-mac-creator="0";
	name="peak.binding.components.py.patch"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
 filename="peak.binding.components.py.patch"

LS0tIGNvbXBvbmVudHMucHkJMjAxNS0wOS0yOSAxNTo1MDo1NS4wMDAwMDAwMDAgKzAzMDAK
KysrIGNvbXBvbmVudHMucHkJMjAxNS0wOS0yOSAxNTo1MjoxMS4wMDAwMDAwMDAgKzAzMDAK
QEAgLTM3OCw3ICszNzgsMTQgQEAKIAogCiAgICAgICAgIGlmIHBjOiAgb2IgPSBwYyhjb21w
b25lbnQpCi0gICAgICAgIGVsc2U6ICAgb2IgPSBhY3F1aXJlQ29tcG9uZW50KGNvbXBvbmVu
dCwgYXR0cikKKyAgICAgICAgZWxzZToKKyAgICAgICAgICAgIHRyeToKKyAgICAgICAgICAg
ICAgICBvYiA9IGFjcXVpcmVDb21wb25lbnQoY29tcG9uZW50LCBhdHRyKQorICAgICAgICAg
ICAgZXhjZXB0IGV4Y2VwdGlvbnMuTmFtZU5vdEZvdW5kLCBfZXhjOgorICAgICAgICAgICAg
ICAgIGlmIGRlZmF1bHQgaXMgbm90IE5PVF9HSVZFTjoKKyAgICAgICAgICAgICAgICAgICAg
cmV0dXJuIGRlZmF1bHQKKyAgICAgICAgICAgICAgICBlbHNlOgorICAgICAgICAgICAgICAg
ICAgICByYWlzZSBfZXhjCiAKICAgICAgICAgcmVzb2x2ZWQgPSBbXQogICAgICAgICBhcHBl
bmQgPSByZXNvbHZlZC5hcHBlbmQK
--------------080708010904010300000007
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
PEAK mailing list
[email protected]
http://www.eby-sarna.com/mailman/listinfo/peak
--------------080708010904010300000007--