Class
zope.i18n.locales.inheritance.InheritingDictionary

Implementation of a dictionary that can also inherit values.

Example:

>>> from zope.i18n.locales.tests.test_docstrings import \
...     LocaleInheritanceStub

>>> root = LocaleInheritanceStub()
>>> root.data = InheritingDictionary({1: 'one', 2: 'two', 3: 'three'})
>>> root.data2 = AttributeInheritance()
>>> root.data2.dict = InheritingDictionary({1: 'i', 2: 'ii', 3: 'iii'})

>>> locale = LocaleInheritanceStub(root)
>>> locale.data = InheritingDictionary({1: 'eins'})
>>> locale.data2 = AttributeInheritance()
>>> locale.data2.dict = InheritingDictionary({1: 'I'})

Here is a dictionary lookup directly from the locale:

>>> locale.data[1]
'eins'
>>> locale.data[2]
'two'

... however, we can also have any amount of nesting:

>>> locale.data2.dict[1]
'I'
>>> locale.data2.dict[2]
'ii'

We also have to overwrite 'get()', 'keys()' and 'items()' since we want to make sure that all upper locales are consulted before returning the default or to construct the list of elements, respectively:

>>> locale.data2.dict.get(2)
'ii'
>>> locale.data2.dict.get(4) is None
True
>>> locale.data.keys()
[1, 2, 3]
>>> locale.data.items()
[(1, 'eins'), (2, 'two'), (3, 'three')]

Base classes

Implemented Interfaces

Attributes/Properties

Methods

Known Subclasses

There are no known subclasses.