The Session class provides a simple way of login and executing function in a server. More...
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. | |
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.
| 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.
| obj | Object name (string) that contains the method | |
| method | Method name (string) to call | |
| args | Argument list for the given method |
| 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.
| 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()
| def Koo::Rpc::Rpc::Session::evaluateExpression | ( | self, | ||
| expression, | ||||
context = None | ||||
| ) |
| def Koo::Rpc::Rpc::Session::execute | ( | self, | ||
| obj, | ||||
| method, | ||||
| args | ||||
| ) |
| 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.
| def Koo::Rpc::Rpc::Session::login | ( | self, | ||
| url, | ||||
| db | ||||
| ) |
Logs in the given server with specified name and password.
| 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 |
| def Koo::Rpc::Rpc::Session::logout | ( | self | ) |
| def Koo::Rpc::Rpc::Session::reloadContext | ( | self | ) |