properly encode and decode from/to utf8 when sending rpc to ikiwiki

somehow, in receive this is not necessary/possible because the xml library expects strings and not unicode
master
Antoine Beaupré 2013-11-29 19:01:30 -05:00
parent 8e458bd659
commit 154c4ea9e6
1 changed files with 3 additions and 3 deletions

View File

@ -159,11 +159,11 @@ class _IkiWikiExtPluginXMLRPCHandler(object):
xml = _xmlrpc_client.dumps(sum(kwargs.items(), args), cmd) xml = _xmlrpc_client.dumps(sum(kwargs.items(), args), cmd)
self._debug_fn( self._debug_fn(
"calling ikiwiki procedure `{0}': [{1}]".format(cmd, xml)) "calling ikiwiki procedure `{0}': [{1}]".format(cmd, xml))
_IkiWikiExtPluginXMLRPCHandler._write(out_fd, xml) _IkiWikiExtPluginXMLRPCHandler._write(out_fd, xml.encode('utf8'))
self._debug_fn('reading response from ikiwiki...') self._debug_fn('reading response from ikiwiki...')
xml = _IkiWikiExtPluginXMLRPCHandler._read(in_fd) xml = _IkiWikiExtPluginXMLRPCHandler._read(in_fd).decode('utf8')
self._debug_fn( self._debug_fn(
'read response to procedure {0} from ikiwiki: [{1}]'.format( 'read response to procedure {0} from ikiwiki: [{1}]'.format(
cmd, xml)) cmd, xml))
@ -250,7 +250,7 @@ class IkiWikiProcedureProxy(object):
# kwargs = dict([args[i:i+2] for i in xrange(1, len(args), 2)]) # kwargs = dict([args[i:i+2] for i in xrange(1, len(args), 2)])
ret = function(self, *args) ret = function(self, *args)
self._debug_fn( self._debug_fn(
"{0} hook `{1}' returned: [{2}]".format(type, name, ret)) "{0} hook `{1}' returned: [{2}]".format(type, name, repr(ret)))
if ret == IkiWikiProcedureProxy._IKIWIKI_NIL_SENTINEL: if ret == IkiWikiProcedureProxy._IKIWIKI_NIL_SENTINEL:
raise InvalidReturnValue( raise InvalidReturnValue(
'hook functions are not allowed to return {0}'.format( 'hook functions are not allowed to return {0}'.format(