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

Lucio Correia luciojhc at linux.vnet.ibm.com
Mon Apr 4 17:45:34 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 | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

Changes in V2: applied review.

diff --git a/src/wok/message.py b/src/wok/message.py
index 7ea5711..a3794d0 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,9 +57,12 @@ 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:
+        text = app.root.messages.get(self.code, self.code)
+        if text == self.code and wok_app is not None:
             app = wok_app
             text = app.root.messages.get(self.code, self.code)
 
-- 
1.9.1




More information about the Kimchi-devel mailing list