[PATCH][Wok] Display Wok messages when requested from plugins

When a plugin makes a request and backend fails in some Wok routine or function, a Wok error message is returned. However, only the message code is displayed not the message text. This patch fixes this problem, so Wok error messages are displayed properly. Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo@linux.vnet.ibm.com> --- src/wok/exception.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/wok/exception.py b/src/wok/exception.py index 878922a..023334b 100644 --- a/src/wok/exception.py +++ b/src/wok/exception.py @@ -43,10 +43,11 @@ class WokException(Exception): # itself to a unicode string. args[key] = unicode(value) - if cherrypy.request.app: + # First, check if it is a Wok error message, then search in plugin + # error messages list + msg = _messages.get(code, code) + if (msg == code) and (cherrypy.request.app): msg = self._get_translation() - else: - msg = _messages.get(code, code) msg = unicode(msg, 'utf-8') % args pattern = "%s: %s" % (code, msg) -- 2.1.0

Reviewed by: Jose Ricardo Ziviani <joserz@linux.vnet.ibm.com> On 07-03-2016 14:04, Rodrigo Trujillo wrote:
When a plugin makes a request and backend fails in some Wok routine or function, a Wok error message is returned. However, only the message code is displayed not the message text. This patch fixes this problem, so Wok error messages are displayed properly.
Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo@linux.vnet.ibm.com> --- src/wok/exception.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/wok/exception.py b/src/wok/exception.py index 878922a..023334b 100644 --- a/src/wok/exception.py +++ b/src/wok/exception.py @@ -43,10 +43,11 @@ class WokException(Exception): # itself to a unicode string. args[key] = unicode(value)
- if cherrypy.request.app: + # First, check if it is a Wok error message, then search in plugin + # error messages list + msg = _messages.get(code, code) + if (msg == code) and (cherrypy.request.app): msg = self._get_translation() - else: - msg = _messages.get(code, code)
msg = unicode(msg, 'utf-8') % args pattern = "%s: %s" % (code, msg)
-- Jose Ricardo Ziviani ----------------------------- Software Engineer Linux Technology Center - IBM

Applied. Thanks. Regards, Aline Manera
participants (3)
-
Aline Manera
-
Jose Ricardo Ziviani
-
Rodrigo Trujillo