zope.container API¶
Interfaces¶
Container-related interfaces
-
exception
zope.container.interfaces.ContainerError[source]¶ Bases:
exceptions.ExceptionAn error of a container with one of its components.
-
interface
zope.container.interfaces.IBTreeContainer[source]¶ Extends:
zope.container.interfaces.IContainerContainer that supports BTree semantics for some methods.
-
keys(key=None)¶ Return an iterator over the keys in the container.
If
Noneis passed as key, this method behaves as if no argument were passed; exactly as required forIContainer.keys().If key is in the container, the first key provided by the iterator will be that key. Otherwise, the first key will be the one that would come next if key were in the container.
-
items(key=None)¶ Return an iterator over the key-value pairs in the container.
If
Noneis passed as key, this method behaves as if no argument were passed; exactly as required forIContainer.items().If key is in the container, the first item provided by the iterator will correspond to that key. Otherwise, the first item will be for the key that would come next if key were in the container.
-
values(key=None)¶ Return an iterator over the values in the container.
If
Noneis passed as key, this method behaves as if no argument were passed; exactly as required forIContainer.values().If key is in the container, the first value provided by the iterator will correspond to that key. Otherwise, the first value will be for the key that would come next if key were in the container.
-
-
interface
zope.container.interfaces.IContainer[source]¶ Extends:
zope.container.interfaces.IReadContainer,zope.container.interfaces.IWriteContainerReadable and writable content container.
-
interface
zope.container.interfaces.IContainerModifiedEvent[source]¶ Extends:
zope.lifecycleevent.interfaces.IObjectModifiedEventThe container has been modified.
This event is specific to “containerness” modifications, which means addition, removal or reordering of sub-objects.
-
interface
zope.container.interfaces.IContainerNamesContainer[source]¶ Extends:
zope.container.interfaces.IContainerContainers that always choose names for their items.
-
interface
zope.container.interfaces.IContentContainer[source]¶ Extends:
zope.container.interfaces.IContainerA container that is to be used as a content type.
-
interface
zope.container.interfaces.IFind[source]¶ Find support for containers.
-
find(id_filters=None, object_filters=None)¶ Find object that matches all filters in all sub-objects.
This container itself is not included.
-
-
interface
zope.container.interfaces.IItemContainer[source]¶ Extends:
zope.interface.common.mapping.IItemMappingMinimal readable container.
-
interface
zope.container.interfaces.IItemWriteContainer[source]¶ Extends:
zope.container.interfaces.IWriteContainer,zope.container.interfaces.IItemContainerA write container that also supports minimal reads.
-
interface
zope.container.interfaces.IOrdered[source]¶ Objects whose contents are maintained in order.
-
updateOrder(order)¶ Revise the order of keys, replacing the current ordering.
order is a list or a tuple containing the set of existing keys in the new order. order must contain
len(keys())items and cannot contain duplicate keys.Raises
TypeErrorif order is not a tuple or a list.Raises
ValueErrorif order contains an invalid set of keys.
-
-
interface
zope.container.interfaces.IOrderedContainer[source]¶ Extends:
zope.container.interfaces.IOrdered,zope.container.interfaces.IContainerContainers whose contents are maintained in order.
-
interface
zope.container.interfaces.IReadContainer[source]¶ Extends:
zope.container.interfaces.ISimpleReadContainer,zope.interface.common.mapping.IEnumerableMappingReadable containers that can be enumerated.
-
interface
zope.container.interfaces.IReservedNames[source]¶ A sequence of names that are reserved for that container
-
reservedNames¶ Reserved Names
Names that are not allowed for addable content
-
-
interface
zope.container.interfaces.ISimpleReadContainer[source]¶ Extends:
zope.container.interfaces.IItemContainer,zope.interface.common.mapping.IReadMappingReadable content containers.
-
interface
zope.container.interfaces.IWriteContainer[source]¶ An interface for the write aspects of a container.
-
__setitem__(name, object)¶ Add the given object to the container under the given name.
Raises a
TypeErrorif the key is not a unicode or ascii string.Raises a
ValueErrorif the key is empty, or if the key contains a character which is not allowed in an object name.Raises a
KeyErrorif the key violates a uniqueness constraint.The container might choose to add a different object than the one passed to this method.
If the object doesn’t implement IContained, then one of two things must be done:
- If the object implements ILocation, then the IContained interface must be declared for the object.
- Otherwise, a ContainedProxy is created for the object and stored.
The object’s __parent__ and __name__ attributes are set to the container and the given name.
If the old parent was
None, then an IObjectAddedEvent is generated, otherwise, an IObjectMovedEvent is generated. An IContainerModifiedEvent is generated for the container.If the object replaces another object, then the old object is deleted before the new object is added, unless the container vetos the replacement by raising an exception.
If the object’s __parent__ and __name__ were already set to the container and the name, then no events are generated and no hooks. This allows advanced clients to take over event generation.
-
__delitem__(name)¶ Delete the named object from the container.
Raises a
KeyErrorif the object is not found.If the deleted object’s __parent__ and __name__ match the container and given name, then an IObjectRemovedEvent is generated and the attributes are set to
None. If the object can be adapted to IObjectMovedEvent, then the adapter’s moveNotify method is called with the event.Unless the object’s __parent__ and __name__ attributes were initially
None, generate an IContainerModifiedEvent for the container.If the object’s __parent__ and __name__ were already set to
None, then no events are generated. This allows advanced clients to take over event generation.
-
-
exception
zope.container.interfaces.InvalidContainerType[source]¶ Bases:
zope.interface.exceptions.Invalid,exceptions.TypeErrorThe type of a container is not valid.
-
exception
zope.container.interfaces.InvalidItemType[source]¶ Bases:
zope.interface.exceptions.Invalid,exceptions.TypeErrorThe type of an item is not valid.
-
exception
zope.container.interfaces.InvalidType[source]¶ Bases:
zope.interface.exceptions.Invalid,exceptions.TypeErrorThe type of an object is not valid.
-
exception
zope.container.interfaces.NameReserved[source]¶ Bases:
exceptions.ValueErrorThe name is reserved for this container
-
exception
zope.container.interfaces.UnaddableError(container, obj, message='')[source]¶ Bases:
zope.container.interfaces.ContainerErrorAn object cannot be added to a container.