Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

django-threadlocals

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

django-threadlocals

Contains utils for storing and retreiving values from threadlocals, and middleware for placing the current Django request in threadlocal storage.

  • 0.10
  • PyPI
  • Socket score

Maintainers
1

Setup/Usage

Install using pip install django-threadlocals

Add threadlocals.middleware.ThreadLocalMiddleware to your MIDDLEWARE_CLASSES setting. Then use it as follows:

Example usage:

from threadlocals.threadlocals import get_current_request

request = get_current_request()

Caveat Emptor

Storing the request in threadlocals goes against several django core developers' strong inclinations against using threadlocals. See this thread on django-users for a more in-depth discussion. We recommend you not do this unless you have a really good reason to do so. We feel like we had a really good reason (the only one we've come across so far): Having the request in threadlocals is the core piece that allowed us to build a true multi-tenant system on top of django where the site is resolved dynamically based on the current host, and objects are filtered based on the current host. With the current version of django, this is nearly impossible to do without the request in threadlocals. This was a very significant and advanced undertaking, but we're happy with the results.

Tests

To run tests:

python tester/manage.py test

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc