{"id":818,"library":"zope-event","title":"Zope Event","description":"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.","status":"active","version":"6.1","language":"python","source_language":"en","source_url":"https://github.com/zopefoundation/zope.event","tags":["events","messaging","pubsub","zope","synchronous"],"install":[{"cmd":"pip install zope.event","lang":"bash","label":"Latest stable version"}],"dependencies":[{"reason":"Required Python version","package":"python","optional":false}],"imports":[{"symbol":"notify","correct":"from zope.event import notify"},{"note":"While directly accessible, higher-level event frameworks typically manage subscriptions without direct manipulation of this list.","symbol":"subscribers","correct":"from zope.event import subscribers"}],"quickstart":{"code":"import zope.event\n\nclass MyEvent:\n    def __init__(self, data):\n        self.data = data\n\ndef my_subscriber(event):\n    print(f\"Subscriber 1 received event with data: {event.data}\")\n\ndef another_subscriber(event):\n    print(f\"Subscriber 2 processed event: {event.data.upper()}\")\n\n# Clear existing subscribers for example isolation (optional for real apps)\n# You might not want to do this in production, especially if other parts\n# of your application register global subscribers.\n_old_subscribers = zope.event.subscribers[:]\ndel zope.event.subscribers[:]\n\n# Register subscribers\nzope.event.subscribers.append(my_subscriber)\nzope.event.subscribers.append(another_subscriber)\n\n# Create and notify an event\nevent = MyEvent(\"hello world\")\nzope.event.notify(event)\n\n# Unsubscribe (optional)\nzope.event.subscribers.remove(my_subscriber)\nzope.event.subscribers.remove(another_subscriber)\n\n# Restore original subscribers (if applicable)\nzope.event.subscribers.extend(_old_subscribers)\n\n# Example of notifying with a simple object (any object can be an event)\nzope.event.notify(42)\nzope.event.notify(\"a string event\")\n\nprint(\"\\nDemonstrating direct manipulation of subscribers (for testing/setup):\")\n# Direct manipulation of the subscribers list is often used in tests\n# or initialization, but higher-level frameworks like zope.component\n# provide more sophisticated subscription mechanisms.\nprint(f\"Current subscribers: {zope.event.subscribers}\")","lang":"python","description":"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."},"warnings":[{"fix":"Upgrade `zc.buildout` to version 5 if encountering namespace resolution issues, or ensure your build system is compatible with PEP 420 native namespaces.","message":"Version 6.0 replaced `pkg_resources` namespace with PEP 420 native namespaces, which might require `zc.buildout` version 5 if your project uses it.","severity":"breaking","affected_versions":"6.0 and later"},{"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`.","message":"Version 6.1 dropped support for Python 3.9 and removed `setuptools` as a runtime dependency.","severity":"breaking","affected_versions":"6.1 and later"},{"fix":"Upgrade your Python environment to 3.10 or newer to use `zope.event` version 6.x.","message":"Version 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.","severity":"breaking","affected_versions":"5.0, 5.1 and later"},{"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.","message":"The `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.","severity":"gotcha","affected_versions":"All versions"},{"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.","message":"While 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`.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-05-12T19:51:02.863Z","next_check":"2026-06-27T00:00:00.000Z","problems":[{"fix":"pip install zope.event","cause":"The `zope.event` package is not installed in the current Python environment.","error":"ModuleNotFoundError: No module named 'zope.event'"},{"fix":"from zope.event import notify","cause":"The `notify` function was called without being imported from the `zope.event` package.","error":"NameError: name 'notify' is not defined"},{"fix":"from zope.event import notify","cause":"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`.","error":"ModuleNotFoundError: No module named 'zope.event.notify'"},{"fix":"from zope.event import subscribers\ndef my_handler(event): pass\nsubscribers.append(my_handler)","cause":"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`.","error":"AttributeError: module 'zope.event' has no attribute 'subscribe'"}],"ecosystem":"pypi","meta_description":null,"install_score":80,"install_tag":"verified","quickstart_score":null,"quickstart_tag":null,"pypi_latest":"6.2","cli_name":null,"install_checks":{"last_tested":"2026-05-12","tag":"verified","tag_description":"installs cleanly on critical runtimes, fast import, recently tested","results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"17.8M"},{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"17.8M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.5,"import_time_s":0,"mem_mb":0,"disk_size":"18M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"18M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"19.6M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"19.6M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.6,"import_time_s":0,"mem_mb":0,"disk_size":"20M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"20M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"11.5M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"11.5M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.4,"import_time_s":0,"mem_mb":0,"disk_size":"12M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"12M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"11.3M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"11.2M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.4,"import_time_s":0,"mem_mb":0,"disk_size":"12M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"12M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"17.3M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"17.3M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.8,"import_time_s":0,"mem_mb":0,"disk_size":"18M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"18M"}]},"quickstart_checks":{"last_tested":"2026-04-24","tag":null,"tag_description":null,"results":[{"runtime":"python:3.10-alpine","exit_code":0},{"runtime":"python:3.10-slim","exit_code":0},{"runtime":"python:3.11-alpine","exit_code":0},{"runtime":"python:3.11-slim","exit_code":0},{"runtime":"python:3.12-alpine","exit_code":0},{"runtime":"python:3.12-slim","exit_code":0},{"runtime":"python:3.13-alpine","exit_code":0},{"runtime":"python:3.13-slim","exit_code":0},{"runtime":"python:3.9-alpine","exit_code":0},{"runtime":"python:3.9-slim","exit_code":0}]}}