Based in all comments I will follow the second approach I proposed.
That way we just translate messages in a single place.
On 01/31/2014 07:17 PM, aline.manera(a)gmail.com wrote:
Or even better, we map all code and messages on UI (i18n.html) and
backend returns the code and params.
For example:
KimchiError('VMERRO01', 'my-vm')
And on UI:
i18n[code], params
That way the translation will be done just in one place - UI
But while using the REST API we will return code and params - not a
full message.
(I am not sure I like it)
What do you think about those 2 proposals?
On Jan 31, 2014 4:21 PM, "Aline Manera" <alinefm(a)linux.vnet.ibm.com
<mailto:alinefm@linux.vnet.ibm.com>> wrote:
From: Aline Manera <alinefm(a)br.ibm.com <mailto:alinefm@br.ibm.com>>
Hi all,
This is the RFC for the refactor exception task.
Sheldon has already done something related to that some time ago.
He also created a wiki for that:
-
https://github.com/kimchi-project/kimchi/wiki/refactor-exception
The only change I made in him approach is translating the message
in backend
and send it to UI
That way we don't need to duplicate the messages on backend and UI
(as it is
explained on wiki)
The steps to get it done:
1) Change cherrypy error handler to send the exception data to UI
2) Create a common Exception class (KimchiError) to translate the
error message
and proper set the parameters
3) Update UI to show the message received from backend to the user
I also would like to create a file on backend: __messages__.py
which will
contain all messages used on backend.
For example:
# __messages__.py
VM_START_FAILED = "<code>: Failed to start virtual machine %(name)s"
The contants names should be: <resource>_<action>_<error>
The <code> need to be a unique value between all messages.
It is needed in order to we identify the error independent of the
message
language.
That way a user running Kimchi in German can easily post his error
on mail list
or github, and we can identify where the problem is by the message
code.
I also will add this code in the UI messages.
For the code, we can build it like:
<resource><BACK|UI><type-of-error><ident>
And on backend:
VMBACKINFO01
VMBACKERRO01
VMBACKWARN01
And on UI:
VMUIINFO01
VMUIERRO01
VMUIWARN01
So we will also need:
4) Create a __messages__ file with all messages used on backend
5) Update build process to add the messages in this file to .po files
6) Update UI messages to add a code for them
I made a small patch set with my proposal.
This patch set does not include the items 4,5 and 6
In fact, I used an existent message for test (as you can notice on
patches)
And *just for example* it will *always* raise an exception while
starting a VM.
Any comments/suggestions are welcome. =)
Aline Manera (2):
refactor exception: Create a common Exception to translate error
messages
refator exception: Example of use
ShaoHe Feng (1):
refactor exception: Add a kimchi special error handler
src/kimchi/control/base.py | 5 ++++-
src/kimchi/exception.py | 29 ++++++++++++++++++++++-------
src/kimchi/model/vms.py | 4 +++-
src/kimchi/template.py | 14 ++++++++++++++
ui/js/src/kimchi.guest_main.js | 4 ++--
5 files changed, 45 insertions(+), 11 deletions(-)
--
1.7.10.4
_______________________________________________
Kimchi-devel mailing list
Kimchi-devel(a)ovirt.org <mailto:Kimchi-devel@ovirt.org>
http://lists.ovirt.org/mailman/listinfo/kimchi-devel
_______________________________________________
Kimchi-devel mailing list
Kimchi-devel(a)ovirt.org
http://lists.ovirt.org/mailman/listinfo/kimchi-devel