Specifications
An interface specification is used to track interface declarations and component registrations.
This class is a base class for both interfaces themselves and for interface specifications (declarations).
Specifications are mutable. If you reassign their cases, their relations with other specifications are adjusted accordingly.
For example:
>>> from zope.interface import Interface >>> class I1(Interface): ... pass >>> class I2(I1): ... pass >>> class I3(I2): ... pass
>>> [i.__name__ for i in I1.__bases__] ['Interface']
>>> [i.__name__ for i in I2.__bases__] ['I1']
>>> I3.extends(I1) 1
>>> I2.__bases__ = (Interface, )
>>> [i.__name__ for i in I2.__bases__] ['Interface']
>>> I3.extends(I1) 0
There are no attributes in this class.
implementedBy(...)
Test whether the specification is implemented by a class or factory. Raise TypeError if argument is neither a class nor a callable.
isOrExtends(...)
Test whether a specification is or extends another
providedBy(...)
Test whether an interface is implemented by the specification
changed(originally_changed)
We, or something we depend on, have changed
extends(interface, strict=True)
Does the specification extend the given interface?
Test whether an interface in the specification extends the given interface
Examples:
>>> from zope.interface import Interface >>> from zope.interface.declarations import Declaration >>> class I1(Interface): pass ... >>> class I2(I1): pass ... >>> class I3(Interface): pass ... >>> class I4(I3): pass ... >>> spec = Declaration() >>> int(spec.extends(Interface)) 1 >>> spec = Declaration(I2) >>> int(spec.extends(Interface)) 1 >>> int(spec.extends(I1)) 1 >>> int(spec.extends(I2)) 1 >>> int(spec.extends(I3)) 0 >>> int(spec.extends(I4)) 0 >>> I2.extends(I2) 0 >>> I2.extends(I2, False) 1 >>> I2.extends(I2, strict=False) 1
get(name, default=None)
Query for an attribute description
interfaces()
Return an iterator for the interfaces in the specification
for example:
>>> from zope.interface import Interface >>> class I1(Interface): pass ... >>> class I2(I1): pass ... >>> class I3(Interface): pass ... >>> class I4(I3): pass ... >>> spec = Specification((I2, I3)) >>> spec = Specification((I4, spec)) >>> i = spec.interfaces() >>> i.next().getName() 'I4' >>> i.next().getName() 'I2' >>> i.next().getName() 'I3' >>> list(i) []
subscribe(dependent)
unsubscribe(dependent)
weakref(callback=None)