containers(*types)
Declare the container types a type can be contained in
This is used within a class suite defining an interface to create a __parent__ specification with a constraint allowing only the given types:
>>> class IFoo(IContainer): ... pass >>> class IBar(IContainer): ... pass>>> from zope.app.container.interfaces import IContained >>> class IFooBarContained(IContained): ... containers(IFoo, IBar)>>> __parent__ = IFooBarContained['__parent__'] >>> __parent__.constraint.types == (IFoo, IBar) True
It is invalid to call containers outside a class suite:
>>> containers(IFoo, IBar) Traceback (most recent call last): ... TypeError: containers not called from suite