RPC made even easier

Albert Cervera i Areny Aug 23, 2008

As I exposed in my previous post, the KDE client provides a set of libraries for developers to use to create new applications easily while using the OpenObject server for data storage and management. The module of the library I'll blog about today is Rpc.

RPC itself is pretty easy to use under python if you use XML-RPC for which OpenObject server already provides an interface. But what if you want to use Net-RPC because of its better performance? KDE client RPC library encapuslates the underlaying protocol to the developer and provides an easy to use interface even for asynchronous queries, which let the user interface keep responding while the queries are run in the background.

Before I go into the details let me advise that we're currently working on some API cleanup and consistency checks. Some modules are being renamed and the old 'ktiny' name will be changed to 'Koo' (which stands for 'KDE OpenObject').

That said, let's see a simple example:

import Koo.Rpc session = Koo.Rpc.Session() session.login( 'http://admin:admin@localhost:8069', 'database' ) #or: session.login( 'socket://admin:admin@localhost:8069', 'database' ) session.call( '/object', 'execute', 'res.partner', 'search', [('name','ilike','NaN')] ) session.logout()</code>

Alternatively if you're building a GUI application you may use asynchronous calls like this:

class MainWindow(QMainWindow):