← Back to team overview

c2c-oerpscenario team mailing list archive

[Bug 689575] [NEW] XMLRPC can't handle non-strings as keys

 

Public bug reported:

I recently came across the problem described at
http://www.openerp.com/forum/post22813.html - namely that several
functions return dictionaries of the format {id1: result1, id2:
result2}.

When accessing these functions through XMLRPC (at least using python's
xmlrpclib), the use of integer ids as keys causes an error. For example,
the following code snippet (using get_product_available from
addons/stock/product.py):

stocknum = sock.execute(db, uid, pass, 'product.product',
'get_product_available', p['id'], {'location': stockid})

Results in the traceback:

  File "/usr/lib/python2.6/xmlrpclib.py", line 1199, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib/python2.6/xmlrpclib.py", line 1489, in __request
    verbose=self.__verbose
  File "/usr/lib/python2.6/xmlrpclib.py", line 1253, in request
    return self._parse_response(h.getfile(), sock)
  File "/usr/lib/python2.6/xmlrpclib.py", line 1392, in _parse_response
    return u.close()
  File "/usr/lib/python2.6/xmlrpclib.py", line 838, in close
    raise Fault(**self._stack[0])
xmlrpclib.Fault: <Fault 1: "<type 'exceptions.TypeError'>:dictionary key must be string">

I'm not very experienced with XMLRPC, so apologies if this is a problem
specific to python's xmlrpclib, or my use of it.

But if not, then perhaps a solution similar to the last patch proposed
on the above forum post - ensuring dict keys are run through str() -
would be wise.

This is with OpenERP 5 rev. 2159.

** Affects: openobject-server
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of C2C
OERPScenario, which is subscribed to the OpenERP Project Group.
https://bugs.launchpad.net/bugs/689575

Title:
  XMLRPC can't handle non-strings as keys

Status in OpenObject Server:
  New

Bug description:
  I recently came across the problem described at http://www.openerp.com/forum/post22813.html - namely that several functions return dictionaries of the format {id1: result1, id2: result2}.

When accessing these functions through XMLRPC (at least using python's xmlrpclib), the use of integer ids as keys causes an error. For example, the following code snippet (using get_product_available from addons/stock/product.py):

stocknum = sock.execute(db, uid, pass, 'product.product', 'get_product_available', p['id'], {'location': stockid})

Results in the traceback:

  File "/usr/lib/python2.6/xmlrpclib.py", line 1199, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib/python2.6/xmlrpclib.py", line 1489, in __request
    verbose=self.__verbose
  File "/usr/lib/python2.6/xmlrpclib.py", line 1253, in request
    return self._parse_response(h.getfile(), sock)
  File "/usr/lib/python2.6/xmlrpclib.py", line 1392, in _parse_response
    return u.close()
  File "/usr/lib/python2.6/xmlrpclib.py", line 838, in close
    raise Fault(**self._stack[0])
xmlrpclib.Fault: <Fault 1: "<type 'exceptions.TypeError'>:dictionary key must be string">

I'm not very experienced with XMLRPC, so apologies if this is a problem specific to python's xmlrpclib, or my use of it.

But if not, then perhaps a solution similar to the last patch proposed on the above forum post - ensuring dict keys are run through str() - would be wise.

This is with OpenERP 5 rev. 2159.





Follow ups

References