Function
zope.interface.declarations.classImplementsOnly

Signature

classImplementsOnly(cls, *interfaces)

Documentation String

Declare the only interfaces implemented by instances of a class

The arguments after the class are one or more interfaces or interface specifications (IDeclaration objects).

The interfaces given (including the interfaces in the specifications) replace any previous declarations.

Consider the following example:

>>> from zope.interface import Interface
>>> class I1(Interface): pass
...
>>> class I2(Interface): pass
...
>>> class I3(Interface): pass
...
>>> class I4(Interface): pass
...
>>> class A(object):
...   implements(I3)
>>> class B(object):
...   implements(I4)
>>> class C(A, B):
...   pass
>>> classImplementsOnly(C, I1, I2)
>>> [i.getName() for i in implementedBy(C)]
['I1', 'I2']

Instances of C provide only I1, I2, and regardless of whatever interfaces instances of A and B implement.