Conceived: Late 2009
Implemented: 2009-2011
Commit: ff4fc336fd638b6b16a5445d252770efc62cb84f (current head, more to come)
Implemented: 2009-2011
Commit: ff4fc336fd638b6b16a5445d252770efc62cb84f (current head, more to come)
Note: this protocol is not really guaranteed to deliver real-time results. It only promises best-effort flowBut, still, we don't want to define a different RPC protocol, a socket opened from the server to the client. We stick with the existing Net-RPC or HTTP implementations, from client to server.
bc_obj = self.pool.get('base.command.address')Client code:
proxy = bc_obj.get_proxy(cr, uid, 'software_dev.buildbot:%d' % (bbid))
proxy.triggerMasterRequests()
class MasterPoller:
@call_with_master
def triggerMasterRequests(self, master):
d = master.pollDatabaseBuildRequests()
return d
Note that the name is RPC-JSON rather than JSON-RPC. It has to be a different name, since this implementation is not strictly a vanilla JSON-RPC one. We are compatible, but not limited to a strict JSON-RPC specification.
GET /json/orm/db-name/res.partner/read?0=123and fetch the data of res.partner[123] in a JSON packet. (you will be asked for http authentication, of course)
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.'}]
>>>
if Some-strange-condition:
. if self._debug:
. . logger.debug("Our object has %s" % self.strange_field)
BQI> orm ir.attachment
BQI ir.attachment> debug object on
BQI ir.attachment> do search([])
[...] DEBUG:http:MultiHttpHandler init for ('127.0.0.1', 34760)
[...] DEBUG:orm:Generate order from create_date desc and None
[...] DEBUG:db.cursor:Q: SELECT "ir_attachment".id FROM "ir_attachment" ORDER BY create_date desc
[...] DEBUG:orm:ir.attachment.read([5, 4], fields=['id', 'res_model'])
[...] DEBUG:orm:ir.attachment.read_flat: tables=['"ir_attachment"'], fields_pre=['res_model']
Command 'execute' returned from server
[...] DEBUG:db.cursor:Q: SELECT id,"res_model" FROM "ir_attachment" WHERE id = ANY(ARRAY[5, 4])ORDER BY create_date desc
[...] DEBUG:db.cursor:Q: SELECT id,"res_model" FROM "ir_attachment" WHERE id = ANY(ARRAY[5, 4])ORDER BY create_date desc
Res: [5, 4]