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