Changed DictModel to dict with attribute access
DictModel is a dict where keys are accessible via attribute access.
The old version was an object with attributes created from dict keys and many
attributes where accessible only via getattr because they did not have a valid
python attribute naming (i.e.: 'provider:network_type' is not a valid
python variable/attribute name)::
>>> d.provider:network_type
File "<stdin>", line 1
d.provider:network_type
^
SyntaxError: invalid syntax
This time we just subclass dict with attribute access to keys.
So dict keys are accessible via attribute access but remain accessible via key
access::
>>> d = DictModel({'foo': 'bar', 'provider:network_type': 'something'})
>>> d.foo == d['foo']
... True
>>> getattr(d, 'provider:network_type') == d.get('provider:network_type')
... True
>>> getattr(d, 'provider:network_type') == d['provider:network_type']
... True
One of the big advantages when debugging is that now in pdb, pp(d) (where d is
a DictModel instance) shows a nice dictionary structure, while with the old
version whe had to perform a "dir(d)" and introspect each attribute...
Change-Id: I05fad7cd9763f97f61680d45e1b6592a80049541
Closes-Bug:
1251653