Middlewares

thread_local

this middleware takes the user from a request and places it into a threadlocal, so it can be retrieved in other contests

Stolen from a mail to django usergroup by Luke Plant - 17.6.2006

jmb.core.middleware.thread_local.get_current_user()[source]

Return the user in the current thread

Tipical usage:

from jmb.core.middleware.thread_local import get_current_user
user = get_current_user()

When working in the shell you can pretend you are a user using setting INTERACTIVE_USER in django.conf.settings. That’s easily done via the jmb.core.conf.set_interactive_user()

from jmb.core.conf import set_interactive_user
set_interactive_user('admin')