6 Sep 15:37
Re: [Traits] dirty trait metadata
Robert Kern wrote: > On Sat, Sep 6, 2008 at 00:33, Prabhu Ramachandran > <prabhu@...> wrote: >> Robert Kern wrote: >> >>>> Is there a simple way of doing this? I know that I could achieve this >>>> if I implemented x as a Property(Array) but is there an easier way? >>> I don't think so. The comparison logic is in C >>> (ctraits.c:setattr_trait), and there are no hooks for this. >>> >>> If you only need coarse-grained notifications, you might consider >>> using an updated Event. This: >> OK, so I came up with a new trait type that does this nicely with minimal >> fuss and also does the validation right. > > What's the use case again? For the one you demonstrated (notification > that an array's contents have changed), I don't think the > ShadowProperty semantics are particularly the obvious way to do issue > that notification. The use case is mayavi's mlab sources. I'd like the user to be able to say obj.mlab_source.x = new_x That new_x may be the same old x but updated. I'd rather not have the user do obj.mlab_source.updated_x = True or whatever after that. This really isn't about notification that an array's contents have changed. It is more of an API issue and a user convenience more than anything. In any case, I've checked it into mayavi so it doesn't affect anyone and it works quite nicely for the mlab source. cheers, prabhu
RSS Feed