[PyQt] question about dip observe handler

Darren Dale dsdale24 at gmail.com
Mon Jul 19 16:13:14 BST 2010


On Mon, Jul 19, 2010 at 9:33 AM, Phil Thompson
<phil at riverbankcomputing.com> wrote:
> On Sun, 18 Jul 2010 18:11:15 -0400, Darren Dale <dsdale24 at gmail.com>
> wrote:
>> I am reading the dip documentation at
>>
> http://www.riverbankcomputing.co.uk/static/Docs/dip/complete_example.html
>> , and have a question about the following:
>>
>> "dip will invoke an observe() handler when the value of an attribute
>> is set, even if the new value is the same as the old one. We therefore
>> use the _propagate_changes attribute to prevent possible recursion
>> problems"
>>
>> Why is it necessary to invoke the observe handler when the value of an
>> attribute does not change? There are quite a few infinite-recursion
>> workarounds in the example. If the possibility of infinite recursion
>> is so high, perhaps by default the handler should not be invoked if
>> the attribute value does not change, unless observe() was called with
>> a kwarg to invoke the handler regardless?
>
> Good question.
>
> The short answer is that it was easiest for me, but (obviously) what
> matters is what's easier for developers using it.

Perhaps the example would be easier to understand (and to develop from
scratch) with such a change.

> The issue is to define what is meant by "changed", particularly when the
> attribute is a class instance? Rebinding the attribute is obviously a
> change, but what about a change to an attribute of the instance?

The last example is another slightly different use case. The way
enthought supports it is documented at
http://code.enthought.com/projects/traits/docs/html/traits_user_manual/notification.html#example-of-a-dynamic-notification-handler
.

Darren


More information about the PyQt mailing list