Zope Container

7.2 · active · verified Thu Apr 16

Zope Container (`zope.container`) is a foundational Python library within the Zope ecosystem, defining interfaces for object container components and providing concrete implementations like BTreeContainer and OrderedContainer. It serves as a building block for dynamic web applications and content management systems such as Plone, offering mechanisms for object persistence, integrity, and access control. Currently at version 7.2, the library maintains an active release cadence, frequently updating to support new Python versions and integrating changes from other Zope core packages.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates creating a basic BTreeContainer, implementing IContainer (a common pattern in Zope to declare interface adherence), and then adding and retrieving items. This showcases the core container functionality.

from zope.container.btree import BTreeContainer
from zope.interface import implementer
from zope.container.interfaces import IContainer

@implementer(IContainer)
class MyContainer(BTreeContainer):
    """A simple container demonstrating zope.container."""
    pass


container = MyContainer()
container['item1'] = 'First Value'
container['item2'] = 123

print(f"Container has {len(container)} items.")
print(f"Item 1: {container['item1']}")

# Iterating through a container
for key, value in container.items():
    print(f"Key: {key}, Value: {value}")

view raw JSON →