[Erp5-report] r39217 jm - in /erp5/trunk/products: ERP5/tests/ ERP5Type/

nobody at svn.erp5.org nobody at svn.erp5.org
Fri Oct 15 11:18:41 CEST 2010


Author: jm
Date: Fri Oct 15 11:18:35 2010
New Revision: 39217

URL: http://svn.erp5.org?rev=39217&view=rev
Log:
ERP5Type.Message: fix retrieval of portal

Modified:
    erp5/trunk/products/ERP5/tests/testPerson.py
    erp5/trunk/products/ERP5Type/Message.py

Modified: erp5/trunk/products/ERP5/tests/testPerson.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/tests/testPerson.py?rev=39217&r1=39216&r2=39217&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/tests/testPerson.py [utf8] (original)
+++ erp5/trunk/products/ERP5/tests/testPerson.py [utf8] Fri Oct 15 11:18:35 2010
@@ -179,8 +179,6 @@ class TestPerson(ERP5TypeTestCase):
   def testPreferenceInteractionWorkflow(self):
     """ when setting reference, a script create preference is
         called by activities, check this behavior. """
-    if not run:
-      return
     person_module = self.getPersonModule()
     title = "Séb"
     person = person_module.newContent(portal_type='Person', title=title)

Modified: erp5/trunk/products/ERP5Type/Message.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Message.py?rev=39217&r1=39216&r2=39217&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Message.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Message.py [utf8] Fri Oct 15 11:18:35 2010
@@ -84,6 +84,8 @@ except ImportError:
 
   getGlobalTranslationService = GlobalTranslationService
 
+translation_service_translate = getGlobalTranslationService().translate
+
 from Products.ERP5Type import Globals
 from cPickle import dumps, loads
 
@@ -135,31 +137,28 @@ class Message(Persistent):
     the return value is a string object. If it is a unicode object,
     the return value is a unicode object.
     """
-    request = Globals.get_request()
-    if request is not None:
-      context = request['PARENTS'][0]
-      translation_service = getGlobalTranslationService()
-
     message = self.message
-    if self.domain is None or request is None or translation_service is None :
+    if self.domain is None:
       # Map the translated string with given parameters
-      if type(self.mapping) is type({}):
+      if type(self.mapping) is dict:
         if isinstance(message, unicode) :
           message = message.encode('utf-8')
         message = Template(message).substitute(self.mapping)
     else:
-      translated_message = translation_service.translate(
+      from Products.ERP5.ERP5Site import getSite
+      translated_message = translation_service_translate(
                                              self.domain,
-                                             self.message,
+                                             message,
                                              mapping=self.mapping,
-                                             context=context,
+                                             context=getSite(),
                                              default=self.default)
       if translated_message is not None:
         message = translated_message
 
-    if isinstance(self.message, str) and isinstance(message, unicode):
-      message = message.encode('utf-8')
-    elif isinstance(self.message, unicode) and isinstance(message, str):
+    if isinstance(self.message, str):
+      if isinstance(message, unicode):
+        message = message.encode('utf-8')
+    elif isinstance(message, str):
       message = message.decode('utf-8')
 
     return message




More information about the Erp5-report mailing list