<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Sorry, I suppose I didn't see the big picture. Anyways, this one
    works as good. I can confirm that in my case (onSubprocessConnected
    = binding.Obtain("onSubprocessConnected", default=lambda connection:
    None) it didn't work before the patch (I define
    onSubprocessConnected in another class up the hierarchy tree).<br>
    <br>
    Thank you for the help! I hope it goes well with the tests.<br>
    <br>
    <br>
    Best regards,<br>
    Alexey<br>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <br>
    <br>
    <div class="moz-cite-prefix">On 31/10/15 16:49, PJ Eby wrote:<br>
    </div>
    <blockquote
cite="mid:CALeMXf4M5x2QdUr2N3hVbKMP3DXEz6Rj8Op8DVdQzsBmii6gmw@mail.gmail.com"
      type="cite">
      <pre wrap="">That's not a typo.  It's part of a strategy to work with multi-part
names.  If the name is a path like 'foo/bar' and acquiring 'foo'
fails, you should not end up with the 'bar' attribute of your default,
which is what would happen with your version.  My version still has a
bug, in that it doesn't work right with *single*-part names, because
the for-loop doesn't execute in that case.  This code really needs
proper tests, but there were apparently never any real tests for this
functionality in the first place.  Most of PEAK's early code was
developed before "test first" and "test-driven" were my standard
practice.  :-(

Anyway, here's a new version that should fix both issues.  I will have
to see about adding some proper tests for this thing and back-testing
to make sure they fail without the patch.


On Sat, Oct 31, 2015 at 3:09 AM, Alexey Smishlayev <a class="moz-txt-link-rfc2396E" href="mailto:alexey@xtech2.lv">&lt;alexey@xtech2.lv&gt;</a> wrote:
</pre>
      <blockquote type="cite">
        <pre wrap="">It does except for a little typo, at line 60 of the patch it should read "ob
= acquireComponent(component, attr, default)", then it works good. Thank
you!


Best regards,
Alexey


On 30/10/15 20:59, PJ Eby wrote:
</pre>
        <blockquote type="cite">
          <pre wrap="">
Does this patch work for you?

On Wed, Oct 28, 2015 at 8:45 AM, Alexey Smishlayev <a class="moz-txt-link-rfc2396E" href="mailto:alexey@xtech2.lv">&lt;alexey@xtech2.lv&gt;</a>
wrote:
</pre>
          <blockquote type="cite">
            <pre wrap="">
Hi!
How can I get an svn checkout to incorporate described changes and
propose
another patch? This is essential for our software and I'd like to see it
merged in upstream as soon as possible.

Best regards,
Alexey


On 30/09/15 01:53, PJ Eby wrote:
</pre>
            <blockquote type="cite">
              <pre wrap="">
Thanks for reporting the problem.  Unfortunately your patch will mask
any other sort of name error, including one that happens indirectly as
a side effect of the lookup.  I think the correct fix is going to be
to change the nameNotFound() method of config.IConfigurationRoot to
include a default (defaulting to NOT_GIVEN), and have
acquireComponent() take a default and pass it along to nameNotFound().
This would handle the case of a direct lookup failing by returning the
default, but still raise an error for any other part of the process
getting a naming error.

On Tue, Sep 29, 2015 at 9:03 AM, Alexey Smishlayev <a class="moz-txt-link-rfc2396E" href="mailto:alexey@xtech2.lv">&lt;alexey@xtech2.lv&gt;</a>
wrote:
</pre>
              <blockquote type="cite">
                <pre wrap="">
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:

</pre>
                <blockquote type="cite">
                  <pre wrap="">      callback = binding.Obtain("callbackFunction", default=lambda
arg:
None)

</pre>
                </blockquote>
                <pre wrap="">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

_______________________________________________
PEAK mailing list
<a class="moz-txt-link-abbreviated" href="mailto:PEAK@eby-sarna.com">PEAK@eby-sarna.com</a>
<a class="moz-txt-link-freetext" href="http://www.eby-sarna.com/mailman/listinfo/peak">http://www.eby-sarna.com/mailman/listinfo/peak</a>
</pre>
              </blockquote>
            </blockquote>
            <pre wrap="">

_______________________________________________
PEAK mailing list
<a class="moz-txt-link-abbreviated" href="mailto:PEAK@eby-sarna.com">PEAK@eby-sarna.com</a>
<a class="moz-txt-link-freetext" href="http://www.eby-sarna.com/mailman/listinfo/peak">http://www.eby-sarna.com/mailman/listinfo/peak</a>
</pre>
          </blockquote>
        </blockquote>
        <pre wrap="">


_______________________________________________
PEAK mailing list
<a class="moz-txt-link-abbreviated" href="mailto:PEAK@eby-sarna.com">PEAK@eby-sarna.com</a>
<a class="moz-txt-link-freetext" href="http://www.eby-sarna.com/mailman/listinfo/peak">http://www.eby-sarna.com/mailman/listinfo/peak</a>
</pre>
      </blockquote>
    </blockquote>
    <br>
  </body>
</html>