Trees | Index | Help |
|
---|
Package zope :: Package i18n :: Package locales :: Module inheritance :: Class InheritingDictionary |
|
object
--+ |dict
--+ |object
--+ | | |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')]
Method Summary | |
---|---|
See zope.i18n.interfaces.locales.ILocaleInheritance | |
See zope.i18n.interfaces.locales.ILocaleInheritance | |
See zope.i18n.interfaces.locales.ILocaleInheritance | |
items(self)
| |
keys(self)
| |
value(self)
| |
Inherited from Inheritance | |
See zope.i18n.interfaces.locales.ILocaleInheritance | |
Inherited from dict | |
x.__init__(...) initializes x; see x.__class__.__doc__ for signature | |
x.__cmp__(y) <==> cmp(x,y) | |
D.__contains__(k) -> True if D has a key k, else False | |
x.__delitem__(y) <==> del x[y] | |
x.__eq__(y) <==> x==y | |
x.__ge__(y) <==> x>=y | |
x.__getattribute__('name') <==> x.name | |
x.__gt__(y) <==> x>y | |
x.__hash__() <==> hash(x) | |
x.__iter__() <==> iter(x) | |
x.__le__(y) <==> x<=y | |
x.__len__() <==> len(x) | |
x.__lt__(y) <==> x<y | |
x.__ne__(y) <==> x!=y | |
T.__new__(S, ...) -> a new object with type S, a subtype of T | |
x.__repr__() <==> repr(x) | |
D.clear() -> None. | |
D.copy() -> a shallow copy of D | |
D.has_key(k) -> True if D has a key k, else False | |
D.iteritems() -> an iterator over the (key, value) items of D | |
D.iterkeys() -> an iterator over the keys of D | |
D.itervalues() -> an iterator over the values of D | |
If key is not found, d is returned if given, otherwise KeyError is raised | |
2-tuple; but raise KeyError if D is empty | |
D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D | |
D.update(E, **F) -> None. | |
D.values() -> list of D's values | |
Inherited from object | |
x.__delattr__('name') <==> del x.name | |
helper for pickle | |
helper for pickle | |
x.__setattr__('name', value) <==> x.name = value | |
x.__str__() <==> str(x) | |
Inherited from type | |
v defaults to None. |
Class Variable Summary | |
---|---|
Implements |
__implemented__ = <implementedBy zope.i18n.locales.inher...
|
ClassProvides |
__provides__ = <zope.interface.declarations.ClassProvide...
|
Inherited from Inheritance | |
str |
__name__ = 'Inheritance'
|
NoneType |
__parent__ = None |
ClassProvides |
__providedBy__ = <zope.interface.declarations.ClassProvi...
|
Method Details |
---|
__getitem__(self,
name)
See zope.i18n.interfaces.locales.ILocaleInheritance
|
__setitem__(self,
name,
value)
See zope.i18n.interfaces.locales.ILocaleInheritance
|
get(self, name, default=None)See zope.i18n.interfaces.locales.ILocaleInheritance
|
Class Variable Details |
---|
__implemented__
|
__provides__
|
Trees | Index | Help |
|
---|
Generated by Epydoc 2.1 on Fri Jun 24 12:01:22 2005 | http://epydoc.sf.net |