Registry / web-framework / zope-container

zope-container

JSON →
library7.2pypypi✓ verified 84d ago

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.

pip install zope-container
INSTALL
IMPORT
SIG · ZOPE-CONTAINER
Z
zope-container
web-frameworkpythonv7.2
Install
5.2s avg
Import
352ms
Disk
48MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v7.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
build_error
glibc
py 3.103.910 runs
installs and imports cleanly · install 5.2s · import 0.352s · 43MB
48MB installed
● package 48MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

BTreeContainer
from zope.container.btree import BTreeContainer
OrderedContainer
from zope.container.ordered import OrderedContainer
IContainer
from zope.container.interfaces import IContainer
IWriteContainer
from zope.container.interfaces import IWriteContainer

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}")
Debug
Known issues
breakingMajor versions of `zope.container` (e.g., 5.0, 6.0, 7.0, 7.1) frequently drop support for older Python versions. Ensure your environment meets the `requires_python` specification (currently >=3.10 for 7.2).
fix
Upgrade your Python interpreter to a supported version or pin `zope-container` to an older version compatible with your Python environment. Refer to PyPI for specific version requirements.
affects: 5.0, 6.0, 7.0, 7.1, 7.2
breakingVersion 7.0 of `zope.container` (and other Zope packages) migrated from `pkg_resources` to PEP 420 native namespace packages. This can affect how sub-packages are discovered and imported in complex Zope deployments.
fix
Ensure your project's packaging and import mechanisms are compatible with PEP 420 namespace packages. This is typically handled automatically by modern Python packaging tools, but older setups might require adjustment.
affects: >=7.0
breakingOlder versions of `zope.interface` (a core dependency) had significant breaking changes in version 6.0 and 7.0, including the removal of deprecated `implements` and `classProvides` functions in favor of `@implementer` and `@provider` decorators. Although `zope.container` itself adopted these earlier (e.g., 4.0.0a1 for `implementer`), downstream code might break.
fix
Update code that declares interfaces or implementations to use the `@implementer` and `@provider` decorators from `zope.interface`. For example, replace `implements(IMyInterface)` with `@implementer(IMyInterface)`.
affects: Zope.interface versions >=6.0.0, indirectly affecting zope.container users with old interface declarations.
gotchaBefore `zope.container` version 3.7.1, certain container operations raised custom exceptions like `zope.exceptions.DuplicationError` or `zope.exceptions.UserError`. These were changed to standard Python exceptions `KeyError` and `ValueError` respectively.
fix
If working with very old code or migrating from it, update exception handling to catch `KeyError` and `ValueError` instead of the former `zope.exceptions` types.
affects: <3.7.1
Errors
Common errors & fixes
ImportError: No module named 'zope.container.old_module'
An import path for a Zope component has changed, or a compatibility import has been removed in a newer version of `zope.container` or a related Zope package.
fix
Consult the `zope.container` changelog or the documentation for the specific Zope package that the module belongs to. For example, `IContained` moved to `zope.location.interfaces` in older versions.
TypeError: ('Could not adapt', <object>, <Interface>)
This often indicates a mismatch in interface declarations or an object not properly implementing a required interface, especially after updates to `zope.interface` or related Zope packages.
fix
Verify that all classes intended to implement `zope.container` interfaces (like `IContainer`, `IWriteContainer`) correctly use the `@implementer` decorator from `zope.interface` and that the object itself is registered or configured to be adaptable. Ensure `zope.interface` and other Zope packages are compatible versions.
KeyError: 'item_name' or ValueError: 'Invalid item name'
In modern versions (>=3.7.1), `zope.container` raises standard `KeyError` for duplication or missing keys and `ValueError` for invalid input (e.g., empty or disallowed characters in names) during item addition/retrieval.
fix
Ensure that keys used for adding or accessing items in a container are unique and adhere to naming conventions (e.g., non-empty, valid string characters). Handle `KeyError` for non-existent items or `ValueError` for invalid names.
Upgrade
Version history
7.2latest on PyPI · released Nov 15, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
47 hits · last 30 days
node
36
OpenAI (training)
1
Resources