6 Sep 11:36
[Traits] feature request
From: Prabhu Ramachandran <prabhu@...>
Subject: [Traits] feature request
Newsgroups: gmane.comp.python.enthought.devel
Date: 2008-09-06 09:38:44 GMT
Subject: [Traits] feature request
Newsgroups: gmane.comp.python.enthought.devel
Date: 2008-09-06 09:38:44 GMT
Hi Dave Morrill,
I see from the implementation (from trunk) that the CHasTraits class
defines a _trait_change_notify method that is used in the trait_set
method to disable/enable notifications. Unfortunately, there is no way
to determine from Python if this flag has been set or not. This is
needed if you want to create a Property trait that does the right thing
in its set method. For example:
class Test(HasTraits):
x = Property(Float)
_x = Float
def _get_x(self):
return self._x
def _set_x(self, value):
old = self._x
self._x = value
if old != new:
self.trait_property_changed('x', old, new)
Clearly, this will break the trait_set method when
trait_change_notify=False. I propose to add a
_get_trait_change_notify() to the ctraits.c to be able to get this so
users can write:
if self._get_trait_change_notify():
...
etc. to work around this.
(Continue reading)
RSS Feed