Registry / observability / zope-event

zope-event

JSON →
library6.2pypypi✓ verified 24d ago

The `zope.event` package provides a very basic, synchronous event publishing system. It enables application code to generate events without requiring awareness of the specific frameworks that might handle them. The current version is 6.1, released on 2025-11-07. Zope ecosystem packages typically follow semantic versioning, with minor releases approximately every 2-6 months and major releases every 2-3 years.

pip install zope.event
INSTALL
IMPORT
SIG · ZOPE-EVENT
Z
zope-event
observabilitypythonv6.2
Install
1.6s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v6.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.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.6s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

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

notify
from zope.event import notify
subscribers
from zope.event import subscribers
While directly accessible, higher-level event frameworks typically manage subscriptions without direct manipulation of this list.

To use `zope.event`, you define an event object (which can be any Python object), define callable functions or methods as subscribers that accept the event object, and then add these subscribers to the `zope.event.subscribers` list. The `zope.event.notify()` function is then called with the event object, which dispatches it to all registered subscribers. The quickstart code temporarily clears the global subscriber list for isolation, which is not typical in a running application but useful for isolated examples or testing.

import zope.event class MyEvent: def __init__(self, data): self.data = data def my_subscriber(event): print(f"Subscriber 1 received event with data: {event.data}") def another_subscriber(event): print(f"Subscriber 2 processed event: {event.data.upper()}") # Clear existing subscribers for example isolation (optional for real apps) # You might not want to do this in production, especially if other parts # of your application register global subscribers. _old_subscribers = zope.event.subscribers[:] del zope.event.subscribers[:] # Register subscribers zope.event.subscribers.append(my_subscriber) zope.event.subscribers.append(another_subscriber) # Create and notify an event event = MyEvent("hello world") zope.event.notify(event) # Unsubscribe (optional) zope.event.subscribers.remove(my_subscriber) zope.event.subscribers.remove(another_subscriber) # Restore original subscribers (if applicable) zope.event.subscribers.extend(_old_subscribers) # Example of notifying with a simple object (any object can be an event) zope.event.notify(42) zope.event.notify("a string event") print("\nDemonstrating direct manipulation of subscribers (for testing/setup):") # Direct manipulation of the subscribers list is often used in tests # or initialization, but higher-level frameworks like zope.component # provide more sophisticated subscription mechanisms. print(f"Current subscribers: {zope.event.subscribers}")
Debug
Known issues
breakingVersion 6.0 replaced `pkg_resources` namespace with PEP 420 native namespaces, which might require `zc.buildout` version 5 if your project uses it.
fix
Upgrade `zc.buildout` to version 5 if encountering namespace resolution issues, or ensure your build system is compatible with PEP 420 native namespaces.
affects: 6.0 and later
breakingVersion 6.1 dropped support for Python 3.9 and removed `setuptools` as a runtime dependency.
fix
Ensure your project runs on Python 3.10 or newer. No action needed regarding `setuptools` unless you explicitly relied on it as a runtime dependency of `zope.event`.
affects: 6.1 and later
breakingVersion 5.0 dropped support for Python 2.7, 3.5, and 3.6. Version 5.1 further dropped support for Python 3.7 and 3.8.
fix
Upgrade your Python environment to 3.10 or newer to use `zope.event` version 6.x.
affects: 5.0, 5.1 and later
gotchaThe `zope.event.notify()` function is synchronous. It calls all registered subscribers in sequential order, and the notification process will block until all subscribers have completed their execution.
fix
Design subscribers to be fast-executing. For long-running or I/O-bound operations, offload the work to a background task, thread, or process to prevent blocking the main application flow. Consider using a more advanced event system (like `zope.component` for type-based dispatching) or an asynchronous library if this behavior is problematic.
affects: All versions
gotchaWhile direct manipulation of `zope.event.subscribers` (e.g., `zope.event.subscribers.append()`) is possible, it is generally discouraged for application-level event handling in favor of higher-level frameworks built on top of `zope.event`, such as `zope.component`.
fix
For complex applications, especially those using `zope.interface` or `zope.component`, leverage their provided subscriber registration mechanisms (e.g., ZCML directives or programmatic adapters) rather than directly modifying the global `subscribers` list.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'zope.event'
The `zope.event` package is not installed in the current Python environment.
fix
pip install zope.event
NameError: name 'notify' is not defined
The `notify` function was called without being imported from the `zope.event` package.
fix
from zope.event import notify
ModuleNotFoundError: No module named 'zope.event.notify'
The `notify` function is an attribute of the `zope.event` module, not a submodule, so it cannot be imported directly using `import zope.event.notify`.
fix
from zope.event import notify
AttributeError: module 'zope.event' has no attribute 'subscribe'
The `zope.event` module does not provide direct `subscribe` or `unsubscribe` functions; subscribers are typically registered by appending them to the `zope.event.subscribers` list or via `zope.component`.
fix
from zope.event import subscribers
def my_handler(event): pass
subscribers.append(my_handler)
Upgrade
Version history
6.2latest on PyPI · released Apr 28, 2026
Audit
Dependencies
pythonrequiredRequired Python version
Agent activity
58 hits · last 30 days
node
48
Perplexity
1
OpenAI (training)
1
Resources
zope-event — pip install zope-event · libregistry