opental-checkins
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[OpenTAL-checkins] opental/PlacelessTranslationService Negotiator.py


From: Magnus Heino
Subject: [OpenTAL-checkins] opental/PlacelessTranslationService Negotiator.py
Date: Sat, 25 Jan 2003 03:56:15 -0500

CVSROOT:        /cvsroot/opental
Module name:    opental
Changes by:     Magnus Heino <address@hidden>   03/01/25 03:56:15

Modified files:
        PlacelessTranslationService: Negotiator.py 

Log message:
        store cache in request object

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/opental/opental/PlacelessTranslationService/Negotiator.py.diff?tr1=1.4&tr2=1.5&r1=text&r2=text

Patches:
Index: opental/PlacelessTranslationService/Negotiator.py
diff -u opental/PlacelessTranslationService/Negotiator.py:1.4 
opental/PlacelessTranslationService/Negotiator.py:1.5
--- opental/PlacelessTranslationService/Negotiator.py:1.4       Thu Jan 16 
18:15:43 2003
+++ opental/PlacelessTranslationService/Negotiator.py   Sat Jan 25 03:56:15 2003
@@ -17,7 +17,7 @@
 #    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307, USA
 """
 
-$Id: Negotiator.py,v 1.4 2003/01/16 23:15:43 lalo Exp $
+$Id: Negotiator.py,v 1.5 2003/01/25 08:56:15 magnusheino Exp $
 """
 
 _langPrefsRegistry = []
@@ -77,13 +77,11 @@
 
 
     def getLanguage(self, langs, env):
-        if not hasattr(env, '_pts_negotiator_cache'):
-            env._pts_negotiator_cache = {}
-        cache = env._pts_negotiator_cache
+        # Store cache in request object
+        cache = env.REQUEST.other.setdefault('_pts_negotiator_cache', {})
         langs = tuple(langs)
-        if not cache.has_key(langs):
-            cache[langs] = self._getLanguage(langs, env)
-        return cache[langs]
+
+        return cache.setdefault(langs, self._getLanguage(langs, env))
 
     def _getLanguage(self, langs, env):
         envprefs = getLangPrefsMethod(env)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]