Features from the xrg dungeons

This series of articles aims to guide you through a set of pending features for OpenERP. Some of them are experimental, some more mature, some need to contain their maturing process... (read more)

Monday, April 18, 2011

OpenERP client Library

Status: beta
Gitweb: http://git.hellug.gr/?p=xrg/openerp-libcli
Clone URL: http://members.hellug.gr/xrg/repos/openerp-libcli
Conceived: summer 2010
Implemented: March 2011

The title shall be enough.
One of the goals is to include all the protocol magic in one library, so that client implementations need no more worry about that. Also, non-Python client libraries could use this one as a reference.
So far, Net-RPC, XML-RPCv1, XML-RPCv2 are supported, with Pyro code also pasted in (but not tested, expect it to burst in flames).


Python 2.7.1
>>> from openerp_libclient import rpc
>>> rpc.openSession(proto="http", host='localhost', port='8169', user="admin", passwd="admin", superpass="admin", dbname="test_bqi")
>>> rpc.login()

1
>>> proxy = rpc.RpcProxy('res.partner')
>>> print proxy.read([1])

[{'comment': False, 'ean13': False, 'date': False, 'id': 1, 'city': 'Gerompont', 'user_id': False, 'title': False, 'company_id': [1, 'OpenERP S.A.'], 'parent_id': False, 'employee': False, 'ref': False, 'email': False, 'vat': False, 'website': False, 'customer': True, 'bank_ids': [], 'child_ids': [], 'supplier': False, 'address': [1], 'active': True, 'lang': 'en_US', 'credit_limit': False, 'name': 'OpenERP S.A.', 'phone': '(+32).81.81.37.00', 'mobile': False, 'country': [20, 'Belgium'], 'events': [], 'category_id': []}]
>>> print proxy.read([1], fields=['name', 'date'])
[{'date': False, 'id': 1, 'name': 'OpenERP S.A.'}]
>>>

2 comments:

  1. Hello,

    I really like the openerp-libcli library, however there is a small thing I don't understand.

    I would like to call orm methods with keywords. As far as I can see your library supports this (the "new way" in test-rpc2.py).

    However when trying to use this I get:

    RpcProtocolException: The server we are connected doesn't support keyword arguments.

    Is there anything special on the server I need to do? I am running 6.1 (trunk).

    Thanks in advance.

    Ronald Portier
    ronald@portier.eu

    ReplyDelete
  2. Hello, thanks for your interest in the library.

    FYI, the full capabilities of that library can only be exploited when running the "pg84-next" version of the openerp-server + "trunk-xrg" addons (that contain RPC-JSON). When this library connects to a 6.0 or 6.1 server, it just uses the compatible calls. That's why you get a clear message that some things are not supported.

    Unfortunately, for everybody, OpenERP SA. not only refused to merge in the extensions of pg84, but REMOVED (in 6.1) those hooks that allowed them to function. So, in 6.1, you will be stuck with the 5.0-era protocol.

    http://git.hellug.gr/?p=xrg/openobject-server;a=commit;h=369217cb4f57030f79

    ReplyDelete