Registry / web-framework / zexceptions

zexceptions

JSON →
library6.0pypypi✓ verified 82d ago

zExceptions is a Python library containing common exceptions used primarily within the Zope and Plone web frameworks. It provides specialized exceptions like `NotFound`, `Redirect`, `Unauthorized`, and `Forbidden` that map to HTTP status codes, simplifying error handling in Zope applications. The current version is 6.0, and it follows an infrequent release cadence, often aligning with Zope framework updates.

pip install zexceptions
INSTALL
IMPORT
SIG · ZEXCEPTIONS
Z
zexceptions
web-frameworkpythonv6.0
Install
4.1s avg
Import
Disk
36MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v6.0 · 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
installs and imports cleanly · install 0.0s · import 0.000s · 33.2MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 4.1s · import 0.000s · 34MB
36MB installed
● package 36MB
Code
Verified usage

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

BadRequest
from zExceptions import BadRequest
from zexceptions import NotFound
Forbidden
from zExceptions import Forbidden
from zexceptions import NotFound
HTTPException
from zExceptions import HTTPException
from zexceptions import NotFound

Demonstrates raising and catching common `zexceptions` like `NotFound`, `Unauthorized`, and `Redirect`, typical in a web request handling scenario. `Redirect` takes a `location` and an optional `code` for the HTTP redirect status.

from zexceptions import NotFound, Unauthorized, Redirect def get_resource(resource_id: str, is_authenticated: bool): if resource_id == "non_existent": raise NotFound("The requested resource was not found.") elif resource_id == "private" and not is_authenticated: raise Unauthorized("Authentication required to access this resource.") elif resource_id == "old_path": # Redirect to a new path with a 301 status code raise Redirect(location="/new_path_for_old_resource", code=301) return f"Resource {resource_id} data." # Example Usage: try: print(get_resource("some_item", True)) print(get_resource("private", False)) except NotFound as e: print(f"Caught NotFound: {e}") except Unauthorized as e: print(f"Caught Unauthorized: {e}") except Redirect as e: print(f"Caught Redirect: {e.location} with code {e.code}") try: get_resource("non_existent", True) except NotFound as e: print(f"Caught NotFound (again): {e}")
Debug
Known issues
breakingzexceptions version 6.0 requires Python 3.10 or newer.
fix
Upgrade your Python environment to 3.10 or newer. If you must use an older Python version, pin `zexceptions` to `<6.0`.
affects: 6.0+
breakingThe `HTTPExceptionHandler` class was removed in `zexceptions` 5.0.
fix
If upgrading from `zexceptions < 5.0` to `5.0` or later, code relying on `HTTPExceptionHandler` will break. Remove or refactor code that uses `HTTPExceptionHandler`. Modern Zope/Plone versions handle exceptions directly or through WSGI middleware, making this class obsolete.
affects: 5.0+
gotchaUsing zexceptions outside of a Zope or Plone framework context.
fix
While you can import and raise zexceptions in any Python application, their specific handling (e.g., mapping to HTTP responses) is usually managed by the Zope or Plone framework. Without such a framework, you'll need to implement custom exception handling to convert them into appropriate HTTP responses (e.g., in Flask/Django middleware).
affects: All versions
Upgrade
Version history
6.0latest on PyPI · released Feb 19, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
23 hits · last 30 days
node
18
OpenAI (training)
1
Resources
zexceptions — pip install zexceptions · libregistry