Dynamic handlers with extended trait names specifying metadata aren't called on dynamically added traits
- Dominant language
- Python
- Stars
- 462
- Forks
- 90
- PR merge metrics
- No merged PRs in 30d
Description
I know this is stacking a few "advanced" features on top of each other, but I've run into an issue that I think is a bug instead of expected behavior. I'm adding a trait with some metadata to an instance of a HasTraits-derived class, and then adding a dynamic notification handler that I want called when traits with that metadata change; but it never gets called. A statically defined notification handler with the same extended trait name spec gets called as expected.
A little example:
``` python
from traits.api import HasTraits, Str, on_trait_change
from traits import __version__
__version__ # --> '4.5.0'
class C(HasTraits):
a = Str(meta = True)
b = Str
@on_trait_change('+meta')
def _changed(self, name):
print "called static handler for {0}".format(name)
def handler(name):
print "called dynamic handler for {0}".format(name)
c = C()
c.add_trait("c", Str(meta = True))
c.on_trait_change(handler, "+meta")
c.a = "a" # --> called static handler for a \n called dynamic handler for a
c.b = "b" # --> nothing
c.c = "c" # --> called static handler for c
```
Is this expected behavior? Am I doing something stupid?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.