On Tue, Mar 06, 2007 at 05:43:26PM -0000, evenrik wrote:
> 
> 
> I added a method to threadlocals.py that allows me to set the user so
> I can run code in the shell that depends on get_current_user()
> returning a user:
> 
> def set_current_user(user):
>     _thread_locals.user = user
> 
> This should work for you.

This is just what I did, and in fact I thought is should work, but it does
not. The manager doesn't seem to see the same _thread_locals.


Since I have almost no experience with threading I thought I was wrong. I
will try harder to understand why Managers do not see it.

Thanks also for the hint on the testing suite and the reason why the user
always returns is_authenticated..

sandro

> > > from django.utils._threading_local import local
> > > from django.contrib.auth.models import User
> > > u = User.objects.filter(username='sandro')[0]
> > > print "user %s is authenticated: %s" % (u,u.is_authenticated())
> > > >>> user sandro is authenticated: True
> >
> > > On the other side inside the manager  I use middleware trick
> > >http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUserto get
> > > the user: it works perfectly from the browser but fails to get the
> > > user from the shell even if I write:
> >
> > > _thread_locals = local()
> > > _thread_locals.user = u

-- 
Sandro Dentella  *:-)
http://www.tksql.org                    TkSQL Home page - My GPL work

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to