Function
zope.app.container.constraints.contains

Signature

contains(*types)

Documentation String

Declare that a container type contains only the given types

This is used within a class suite defining an interface to create a __setitem__ specification with a precondition allowing only the given types:

>>> class IFoo(zope.interface.Interface):
...     pass
>>> class IBar(zope.interface.Interface):
...     pass
>>> class IFooBarContainer(IContainer):
...     contains(IFoo, IBar)
>>> __setitem__ = IFooBarContainer['__setitem__']
>>> __setitem__.getTaggedValue('precondition').types == (IFoo, IBar)
True

It is invalid to call contains outside a class suite:

>>> contains(IFoo, IBar)
Traceback (most recent call last):
...
TypeError: contains not called from suite