Well, I wanted locale.format() and locale.currency() to use a per request locale setting, instead of the underlying more "global" one that isn't thread-safe.
So I patched localeconv() to extract the locale setting from the request instead of wherever it gets it otherwise normally. I've read through the locale module, and this seems to be the "deepest" point where to effect the change. This does not make the whole module thread-safe by a long shot, and wasn't intended to. I just wanted number/currency formatting to work, which it does format(), currency(), and _group() are safe). Of course now I've found the Zope 3 Locale and LocaleProvider Implementation, with number and currency and datetime support ... I may try to use that instead. J.F. -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Dieter Maurer Sent: December 17, 2006 3:43 AM To: Doyon, Jean-Francois Cc: Chris Withers; zope@zope.org Subject: RE: [Zope] Zope, setlocale(), requests and traversal Doyon, Jean-Francois wrote at 2006-12-15 08:38 -0500: >setlocale() is a python thing. It wraps a C library, and that function >setups an application wide environment (A bit like an environment >variable would ...) ... Which is why it's not thread safe. If you do not have a thread aware implementation of "setlocale", then it is *VERY* dangerous to change "setlocale" inside a thread -- as changing any global data can lead to non-deterministic behaviour in a multi-threaded environment unless special precautions (locking) are taken. Apparently, you are aware of the danger. But, I have not seen how you avoid the problem in your sketched solution. -- Dieter _______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev ) _______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )