{"id":23020,"library":"zope-globalrequest","title":"zope.globalrequest","description":"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.","status":"active","version":"3.0","language":"python","source_language":"en","source_url":"https://github.com/zopefoundation/zope.globalrequest","tags":["zope","request","global","pyramid","web"],"install":[{"cmd":"pip install zope.globalrequest","lang":"bash","label":"PyPI install"}],"dependencies":[],"imports":[{"note":"","wrong":"","symbol":"getRequest","correct":"from zope.globalrequest import getRequest"},{"note":"","wrong":"","symbol":"setRequest","correct":"from zope.globalrequest import setRequest"},{"note":"","wrong":"","symbol":"clear","correct":"from zope.globalrequest import clear"}],"quickstart":{"code":"from zope.globalrequest import setRequest, getRequest\n\nclass FakeRequest:\n    pass\n\nrequest = FakeRequest()\nsetRequest(request)\nactive = getRequest()\nprint(active)  # <__main__.FakeRequest object at ...>\n","lang":"python","description":"Set and retrieve the current global request."},"warnings":[{"fix":"Set zope.globalrequest.config.SET_AS_COROUTINE_LOCAL = True for async support.","message":"Thread safety: setRequest/getRequest are thread-safe only if config.SET_AS_COROUTINE_LOCAL is False (default). In async contexts, use async local aware patterns.","severity":"gotcha","affected_versions":">=3.0"},{"fix":"Change imports to 'from zope.globalrequest import getRequest'.","message":"The compatibility import from zope.publisher.browser is deprecated. Always import directly from zope.globalrequest.","severity":"deprecated","affected_versions":">=2.0"},{"fix":"Configure via zope.globalrequest.config.set_local_storage('coroutine') or 'thread' explicitly.","message":"Mixing 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.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use 'from zope.globalrequest import getRequest' instead.","cause":"Deprecated import path removed in zope.publisher.","error":"ImportError: cannot import name 'getRequest' from 'zope.publisher.browser'"},{"fix":"Pass a request object: setRequest(request_obj).","cause":"Calling setRequest() without an argument.","error":"TypeError: setRequest() missing 1 required positional argument: 'request'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}