equal
deleted
inserted
replaced
59 |
59 |
60 .. autofunction:: cubicweb.web.views.ajaxcontroller.ajaxfunc |
60 .. autofunction:: cubicweb.web.views.ajaxcontroller.ajaxfunc |
61 |
61 |
62 """ |
62 """ |
63 |
63 |
64 |
64 import http.client as http_client |
65 |
|
66 from functools import partial |
65 from functools import partial |
67 |
|
68 from six import PY2, text_type |
|
69 from six.moves import http_client |
|
70 |
66 |
71 from logilab.common.date import strptime |
67 from logilab.common.date import strptime |
72 from logilab.common.registry import yes |
68 from logilab.common.registry import yes |
73 |
69 |
74 from cubicweb import ObjectNotFound, NoSelectableObject, ValidationError |
70 from cubicweb import ObjectNotFound, NoSelectableObject, ValidationError |
149 fname, args, exc) |
145 fname, args, exc) |
150 raise RemoteCallFailed(exc_message(exc, self._cw.encoding)) |
146 raise RemoteCallFailed(exc_message(exc, self._cw.encoding)) |
151 if result is None: |
147 if result is None: |
152 return b'' |
148 return b'' |
153 # get unicode on @htmlize methods, encoded string on @jsonize methods |
149 # get unicode on @htmlize methods, encoded string on @jsonize methods |
154 elif isinstance(result, text_type): |
150 elif isinstance(result, str): |
155 return result.encode(self._cw.encoding) |
151 return result.encode(self._cw.encoding) |
156 return result |
152 return result |
157 |
153 |
158 class AjaxFunction(AppObject): |
154 class AjaxFunction(AppObject): |
159 """ |
155 """ |