[Kimchi-devel] [PATCH] [Wok] Fix errors in Ginger/Gingerbase/Gingers390x tests

Lucio Correia luciojhc at linux.vnet.ibm.com
Mon Apr 4 16:47:45 UTC 2016


Do not try to translate message when app is not found.

Signed-off-by: Lucio Correia <luciojhc at linux.vnet.ibm.com>
---
 src/wok/message.py | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/wok/message.py b/src/wok/message.py
index 7ea5711..e4ee640 100644
--- a/src/wok/message.py
+++ b/src/wok/message.py
@@ -45,11 +45,11 @@ class WokMessage(object):
         self.plugin = plugin
 
     def _get_translation(self):
-        wok_app = cherrypy.tree.apps['']
+        wok_app = cherrypy.tree.apps.get('', None)
 
         # get app from plugin path if specified
         if self.plugin:
-            app = cherrypy.tree.apps[self.plugin]
+            app = cherrypy.tree.apps.get(self.plugin, None)
         # if on request, try to get app from it
         elif cherrypy.request.app:
             app = cherrypy.request.app
@@ -57,11 +57,13 @@ class WokMessage(object):
         else:
             app = wok_app
 
+        if app is None:
+            return self.code
+
         # fallback to Wok message in case plugins raise Wok exceptions
-        text = app.root.messages.get(self.code, None)
-        if text is None:
-            app = wok_app
-            text = app.root.messages.get(self.code, self.code)
+        text = app.root.messages.get(self.code, self.code)
+        if text == self.code and wok_app is not None:
+            text = wok_app.root.messages.get(self.code, self.code)
 
         # do translation
         domain = app.root.domain
-- 
1.9.1




More information about the Kimchi-devel mailing list