nucleic/atom — pull request #12 by blink1073 (2013-10-23 12:58:35+00:00)
Title: Add a ContainerDict to Support Observation

This is a point of discussion, not a very good implementation. As it stands, this will observe the current state of the dictionary upon accessing it, so it is one step behind in observations when modifying.

```python
from atom.api import Atom, Dict, ContainerDict, observe

class DictDemo(Atom):

cont_dict = ContainerDict()

simple_dict = Dict()

def _observe_simple_dict(self, change):
print 'simple dict change', change['value']

@observe('cont_dict')
def cont_change(self, change):
print 'cont dict change', change['value']

test = DictDemo()
test.simple_dict = dict(foo='hi', bar=1) # prints ['foo', 'bar']
test.cont_dict = dict(spam=1.4, eggs=hex) # prints ['eggs', 'spam']
test.simple_dict['baz'] = 50 # no observation
test.simple_dict['foo'] = 10 # no observation
test.cont_dict['circus'] = 'flying' # prints ['eggs', 'spam']
test.cont_dict['spam'] = 'apple' # prints ['eggs, 'circus', 'spam'] with previous 'spam'
test.cont_dict # prints ['eggs', 'circus', 'spam'] with 'spam' changed
```