[PATCH 5 of 6 rqlcontroller] [py3] Let RqlIOController.publish() return bytes

Denis Laxalde denis.laxalde at logilab.fr
Mon Jun 4 14:28:44 CEST 2018


# HG changeset patch
# User Denis Laxalde <denis.laxalde at logilab.fr>
# Date 1528114579 -7200
#      Mon Jun 04 14:16:19 2018 +0200
# Node ID 6e9a2c47697e4632927fd5b90331f297f1fc3772
# Parent  59eab509372ef275e27d08691da0809fa68b0b0d
# Available At http://hg.logilab.org/review/cubes/rqlcontroller
#              hg pull http://hg.logilab.org/review/cubes/rqlcontroller -r 6e9a2c47697e
# EXP-Topic py3
[py3] Let RqlIOController.publish() return bytes

This is expected by CubicWebPublisher.
We use request's encoding to encode the JSON value.

diff --git a/views.py b/views.py
--- a/views.py
+++ b/views.py
@@ -134,8 +134,8 @@ class RqlIOController(Controller):
         except Exception as exc:
             raise RemoteCallFailed(exc_message(exc, self._cw.encoding))
         if result is None:
-            return ''
-        return json_dumps(result)
+            return b''
+        return json_dumps(result).encode(self._cw.encoding)
 
     def rqlio(self, *rql_args):
         try:


More information about the cubicweb-devel mailing list