Public Member Functions

Koo::Rpc::Rpc::Session Class Reference

The Session class provides a simple way of login and executing function in a server. More...

List of all members.

Public Member Functions

def callAsync
 Calls asynchronously the specified method on the given object on the server.
def executeAsync
 Same as callAsync() but uses the notify mechanism to notify exceptions.
def call
 Calls the specified method on the given object on the server.
def execute
 Same as call() but uses the notify mechanism to notify exceptions.
def login
 Logs in the given server with specified name and password.
def reloadContext
 Reloads the session context.
def logged
 Returns whether the login function has been called and was successfull.
def logout
 Logs out of the server.
def evaluateExpression
 Uses eval to evaluate the expression, using the defined context plus the appropiate 'uid' in it.

Detailed Description

The Session class provides a simple way of login and executing function in a server.

Typical usage of Session:

 from Koo import Rpc
 Rpc.session.login('http://admin:admin\@localhost:8069', 'database')
 attached = Rpc.session.execute('/object', 'execute', 'ir.attachment', 'read', [1,2,3])
 Rpc.session.logout()

Definition at line 335 of file Rpc.py.


Member Function Documentation

def Koo::Rpc::Rpc::Session::call (   self,
  obj,
  method,
  args 
)

Calls the specified method on the given object on the server.

If there is an error during the call it simply rises an exception. See execute() if you want exceptions to be handled by the notification mechanism.

Parameters:
obj Object name (string) that contains the method
method Method name (string) to call
args Argument list for the given method

Definition at line 413 of file Rpc.py.

def Koo::Rpc::Rpc::Session::callAsync (   self,
  callback,
  obj,
  method,
  args 
)

Calls asynchronously the specified method on the given object on the server.

When the response to the request arrives the callback function is called with the returned value as the first parameter. It returns an AsynchronousSessionCall instance that can be used to keep track to what query a callback refers to, consider that as a call id. If there is an error during the call it simply rises an exception. See execute() if you want exceptions to be handled by the notification mechanism.

Parameters:
callback Function that has to be called when the result returns from the server.
exceptionCallback Function that has to be called when an exception returns from the server.
obj Object name (string) that contains the method
method Method name (string) to call
args Argument list for the given method

Example of usage:

 from Koo import Rpc
 def returned(self, value):
        print value
 Rpc.session.login('http://admin:admin\@localhost:8069', 'database')
 Rpc.session.post( returned, '/object', 'execute', 'ir.attachment', 'read', [1,2,3]) 
 Rpc.session.logout()

Definition at line 388 of file Rpc.py.

def Koo::Rpc::Rpc::Session::evaluateExpression (   self,
  expression,
  context = None 
)

Uses eval to evaluate the expression, using the defined context plus the appropiate 'uid' in it.

Definition at line 511 of file Rpc.py.

def Koo::Rpc::Rpc::Session::execute (   self,
  obj,
  method,
  args 
)

Same as call() but uses the notify mechanism to notify exceptions.

Note that you'll need to bind gettext as texts sent to the notify module are localized.

Definition at line 429 of file Rpc.py.

def Koo::Rpc::Rpc::Session::executeAsync (   self,
  callback,
  obj,
  method,
  args 
)

Same as callAsync() but uses the notify mechanism to notify exceptions.

Note that you'll need to bind gettext as texts sent to the notify module are localized.

Definition at line 399 of file Rpc.py.

def Koo::Rpc::Rpc::Session::login (   self,
  url,
  db 
)

Logs in the given server with specified name and password.

Parameters:
url url string such as 'http://admin:admin@localhost:8069'. Admited protocols are 'http', 'https' and 'socket'
db string with the database name Returns Session.Exception, Session.InvalidCredentials or Session.LoggedIn

Definition at line 456 of file Rpc.py.

def Koo::Rpc::Rpc::Session::logout (   self  ) 

Logs out of the server.

Definition at line 499 of file Rpc.py.

def Koo::Rpc::Rpc::Session::reloadContext (   self  ) 

Reloads the session context.

Useful when some user parameters such as language are changed.

Definition at line 491 of file Rpc.py.


The documentation for this class was generated from the following file:
Generated by Doxygen