Support for interface declarations on decorators
>>> from zope.interface import * >>> class I1(Interface): ... pass >>> class I2(Interface): ... pass >>> class I3(Interface): ... pass >>> class I4(Interface): ... pass
>>> class D1(SpecificationDecoratorBase): ... implements(I1)
>>> class D2(SpecificationDecoratorBase): ... implements(I2)
>>> class X(object): ... implements(I3)
>>> x = X() >>> directlyProvides(x, I4)
Interfaces of X are ordered with the directly-provided interfaces first
>>> [interface.getName() for interface in list(providedBy(x))] ['I4', 'I3']
When we decorate objects, what order should the interfaces come in? One could argue that decorators are less specific, so they should come last.
>>> [interface.getName() for interface in list(providedBy(D1(x)))] ['I4', 'I3', 'I1']
>>> [interface.getName() for interface in list(providedBy(D2(D1(x))))] ['I4', 'I3', 'I1', 'I2']
SpecificationDecorators also work with old-style classes:
>>> class X: ... implements(I3)
>>> x = X() >>> directlyProvides(x, I4)
>>> [interface.getName() for interface in list(providedBy(x))] ['I4', 'I3']
>>> [interface.getName() for interface in list(providedBy(D1(x)))] ['I4', 'I3', 'I1']
>>> [interface.getName() for interface in list(providedBy(D2(D1(x))))] ['I4', 'I3', 'I1', 'I2']
There are no implemented interfaces.
There are no attributes in this class.
There are no methods in this class.
There are no known subclasses.