enthought/chaco — pull request #103 by hugadams (2013-02-27 19:11:11+00:00)
Title: Added event handling for added and removed events in update handler of P...

...lot class.

Also modified update handler for changed event to raise error if key not found, instead of just passing.

In old version:

if event.has_key("changed"):
for name in event["changed"]:
if self.datasources.has_key(name):
source = self.datasources[name]
source.set_data(self.data.get_data(name))

In this version:

if event.has_key("changed"):
for name in event["changed"]:
try:
source = self.datasources[name]
except KeyError:
raise KeyError('Datasource has no event "%s"'%name)
else:
source.set_data(self.data.get_data(name))

The old version allowed for the case that an AbstractPlotData subclass could call an event "changed" when it really was added or removed. This would possibly be a problem for custom AbstractPlotData subclasses and should not catch any errors in pre-existing subclasses like ArrayPlotData.