Registry / web-framework / zope-globalrequest

zope-globalrequest

JSON →
library3.0pypypi✓ verified 73d ago

Provides a global way to retrieve the currently active request, commonly used in Zope/ Pyramid applications. Current version: 3.0, requires Python >=3.9. Maintained by the Zope Foundation.

pip install zope.globalrequest
INSTALL
IMPORT
SIG · ZOPE-GLOBALREQUEST
Z
zope-globalrequest
web-frameworkpythonv3.0
Install
4.2s avg
Import
30ms
Disk
37MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v3.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.95 runs
installs and imports cleanly · install 0.0s · import 0.030s · 34MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 4.2s · import 0.030s · 35MB
37MB installed
● package 37MB
Code
Verified usage

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

getRequest
from zope.globalrequest import getRequest
setRequest
from zope.globalrequest import setRequest
clear
from zope.globalrequest import clear

Set and retrieve the current global request.

from zope.globalrequest import setRequest, getRequest class FakeRequest: pass request = FakeRequest() setRequest(request) active = getRequest() print(active) # <__main__.FakeRequest object at ...>
Debug
Known issues
gotchaThread safety: setRequest/getRequest are thread-safe only if config.SET_AS_COROUTINE_LOCAL is False (default). In async contexts, use async local aware patterns.
fix
Set zope.globalrequest.config.SET_AS_COROUTINE_LOCAL = True for async support.
affects: >=3.0
deprecatedThe compatibility import from zope.publisher.browser is deprecated. Always import directly from zope.globalrequest.
fix
Change imports to 'from zope.globalrequest import getRequest'.
affects: >=2.0
gotchaMixing threads and coroutines: if you use both threading and asyncio, you must decide on a single local storage strategy. The default thread-local may cause cross-request leaks.
fix
Configure via zope.globalrequest.config.set_local_storage('coroutine') or 'thread' explicitly.
affects: all
Errors
Common errors & fixes
ImportError: cannot import name 'getRequest' from 'zope.publisher.browser'
Deprecated import path removed in zope.publisher.
fix
Use 'from zope.globalrequest import getRequest' instead.
TypeError: setRequest() missing 1 required positional argument: 'request'
Calling setRequest() without an argument.
fix
Pass a request object: setRequest(request_obj).
Upgrade
Version history
3.0latest on PyPI · released Sep 12, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
31 hits · last 30 days
node
28
OpenAI (training)
1
Resources
zope-globalrequest — pip install zope-globalrequest · libregistry