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

Do not try to translate message when app is not found. Signed-off-by: Lucio Correia <luciojhc@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

On 04/04/2016 01:47 PM, Lucio Correia wrote:
Do not try to translate message when app is not found.
Signed-off-by: Lucio Correia <luciojhc@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)
You still need to assign wok_app to app to look for the translation in the right app.
# do translation domain = app.root.domain
participants (2)
-
Aline Manera
-
Lucio Correia