16 Jul 00:47
Re: probable bug in @on_trait_change with delegated lists
From: David C. Morrill <dmorrill@...>
Subject: Re: probable bug in @on_trait_change with delegated lists
Newsgroups: gmane.comp.python.enthought.devel
Date: 2008-07-15 22:47:18 GMT
Subject: Re: probable bug in @on_trait_change with delegated lists
Newsgroups: gmane.comp.python.enthought.devel
Date: 2008-07-15 22:47:18 GMT
Danny Shevitz wrote:
>> The subtlety is that in my code sub_contexts are delegated through a
>> LogicElement via:
>> context.sub_contexts = context.logic_element.sub_contexts
>>
>> I have a similar version of the code that does not use delegation and does not
>> show the bug. It would seem that the bug is in the combination of catching
>> changes to a delegated list using the '*' pattern.
>>
>
> More debugging...
>
> If I had to guess, I think that the bug is that the pattern
> @on_trait_change('object:list*')
>
> when 'list' is delegated, is causing the wrong handler in traits_listener
> to be used. I think traits_listener.py:522 "handle_list_items" should be used
> but traits_listener.py:506 "handle_list" is being used instead. The result
> is that handle_list is being handed old=Undefined, new=TraitListObject instead
> of old=List, new=List.
>
> I'm not sure why this is happening though...
>
>
I'm not sure why you think that is the wrong handler, especially when
the 'new' value is a TraitListObject? If 'new' were a TraitListEvent
object, then your conjecture would have some merit. See my previous post
about setting a default Property value...
Dave Morrill
RSS Feed