On Wed, 2007-07-11 at 18:57 +0000, Nathaniel Whiteinge wrote: > I'm having a problem with threadlocals in a custom manager making > queries for the wrong user. I've Googled around quite a bit, and > haven't found the answer -- except others *do* seem to be successfully > using threadlocals in Managers. Ostensibly this is a import-time vs. > execution-time problem, but I'm not sure. Can someone identify my > folly? > > class PickManager(models.Manager): > def get_query_set(self): > return super(PickManager, > self).get_query_set().select_related() > > def history(self): > return self.filter(user=threadlocals.get_current_user())
There's no obvious problem here. The get_current_user() call will be made every time history() is called, not at import time. You might to put the debugging a bit higher up in the request processing to see if the user is really being set correctly. Regards, Malcolm -- Plan to be spontaneous - tomorrow. http://www.pointy-stick.com/blog/ --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---