On Mon, 2008-12-22 at 23:09 -0800, Iwan wrote: > Malcolm, > > On Dec 23, 2:00 am, Malcolm Tredinnick <malc...@pointy-stick.com> > wrote: > > You can do it this way: > > > > from django.utils import translation > > > > translation.activate(locale) > > > > where "locale" is a variable containing the name of the locale you wish > > to activate. You should call that as early as possible in the processing > > pipeline once you know the right locale value. > > Thanks. > > Is this thread-safe? I looked at the code in trans_real.py (def > activate), and from my understanding it is not thread-safe, since it > accesses the _active dictionary?
That's a fairly naïve check of thread safeness. :-) Sure, it accesses the global. But it uses the current thread id as the key, which is unique per thread. It's essentially a poor man's threadlocals usage (but slightly better than threadlocals, since it's more encapsulated). Dictionary updates are safe in Python. Regards, Malcolm --~--~---------~--~----~------------~-------~--~----~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---