On Thursday 21 September 2006 21:56, Kr0n wrote:
> ibson wrote:
> > Apologiz for saying it worked!!! It doesn't work after some times
> > even after restarting apache every 15 minutes!!!
> > So the question is always there. And it seems I am not the only to
> > hav this problem
>
> Yep. I've also a problem with this, but for me it's simply doesn't
> work at all. I'm using the info in
> http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser plus
> "limit_choices_to" like ibson but with no success.
>
> Anyone could bring some light on this?

The point at which you are calling 'threadlocals.get_current_user()' is 
when the class is being constructed.  If you have some Python code like 
this:

class Foo:
   bar = do_something()

then do_something() is called when Python reads the module containing 
Foo and executes it, and creates a class object.  This happens *once* 
for top level classes like this (i.e. classes that are not being 
dynamically generated etc), so you can't use this to have data that 
will vary on a per-request basis.  The value of 'bar', 
or 'usergroup=threadlocals.get_current_user()' in the example code, is 
fixed from the first time this module is imported.  Whether the 
threadlocal middleware code has been called at all by this point may 
well depend on import order of the different bits and pieces.

Luke

-- 
Hofstadter's Law: It always takes longer than you expect, even when you 
take into account Hofstadter's Law.

Luke Plant || L.Plant.98 (at) cantab.net || http://lukeplant.me.uk/

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to