<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">于 2014/3/4 0:24, Aline Manera 写道:<br>
</div>
<blockquote cite="mid:5314ACAD.8040709@linux.vnet.ibm.com"
type="cite">
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<div class="moz-cite-prefix">On 03/03/2014 12:20 PM, Shu Ming
wrote:<br>
</div>
<blockquote cite="mid:53149DD6.7080503@linux.vnet.ibm.com"
type="cite">
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<div class="moz-cite-prefix">Shelon,<br>
<br>
I got another idea to check of the string is utf-8 already not
checking the cherrypy's version, see the below:<br>
<pre style="" class="lang-py prettyprint prettyprinted"><code><span class="pln"></span><span class="pun"></span><span class="pln"></span><span class="kwd"></span><span class="pln">
</span><span class="kwd">try</span><span class="pun">:</span><span class="pln">
res</span><span class="pun">.</span><span class="pln">decode</span><span class="pun">(</span><span class="str">'utf-8'</span><span class="pun">)
</span></code><code><span class="pun">res.encode("utf-8")
return res;
</span><span class="pln"> </span><span class="kwd">except</span><span class="pln"> </span><span class="typ">UnicodeDecodeError</span><span class="pun">:</span><span class="pln">
return </span></code>res.encode("utf-8")
</pre>
</div>
</blockquote>
<br>
+1<br>
<br>
We should avoid base our code in the package versions.<br>
That way we make sure the code will code independent of it.<br>
</blockquote>
<br>
After direct talk with Sheldon, the res will return to Cherrypy and
it is Cherrypy to decode the "res" to a string or not based on
Cherrypy's version. Just ignore my method in kimchi, because we
need to check the cherrypy's assumption of the type of "res" to
it. And checking Cherrypy's version is a fast way to know the
assumption. <br>
<br>
<blockquote cite="mid:5314ACAD.8040709@linux.vnet.ibm.com"
type="cite"> <br>
<blockquote cite="mid:53149DD6.7080503@linux.vnet.ibm.com"
type="cite">
<div class="moz-cite-prefix"> <br>
2014/3/3 17:50, Sheldon:<br>
</div>
<blockquote cite="mid:5314505B.6020803@linux.vnet.ibm.com"
type="cite">Now there's a issue: <br>
<a moz-do-not-send="true" class="moz-txt-link-freetext"
href="https://github.com/kimchi-project/kimchi/issues/333">https://github.com/kimchi-project/kimchi/issues/333</a>
<br>
<br>
The reason of this issue is because high level cherrpy version
make some change about set_response. <br>
<br>
The high level cherrpy encode the unicode error message by
itself. <br>
<br>
So the kimchi do not encode the unicode error message any
more. <br>
<br>
It is right, the cherrpy should encode the unicode error
message. <br>
<br>
Now we can require the cherrypy version to solve this problem.
<br>
<br>
we can also check the cherrypy version in kimchi code as
follow in order to avoid to require the cherrypy version. <br>
<br>
like: <br>
if cherrypy.__version__ << 3.2.5: <br>
return res <br>
else: <br>
return res.encode("utf-8") <br>
<br>
</blockquote>
<br>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Kimchi-devel mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:Kimchi-devel@ovirt.org">Kimchi-devel@ovirt.org</a>
<a moz-do-not-send="true" 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>
</blockquote>
<br>
</body>
</html>