~unifield-team/unifield-web/utp-1051

« back to all changes in this revision

Viewing changes to addons/openerp/utils/rpc.py

  • Committer: jf
  • Date: 2014-09-05 08:53:16 UTC
  • mfrom: (4742.2.6 unifield-web)
  • Revision ID: jfb@tempo-consulting.fr-20140905085316-aafb2w44t0zvb39z
Pilot 3.1b7

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
 
29
29
from tiny_socket import TinySocket
30
30
from tiny_socket import TinySocketError
 
31
import cherrypy
 
32
 
31
33
 
32
34
class NotLoggedIn(openobject.errors.TinyError, openobject.errors.AuthenticationError): pass
33
35
 
69
71
    def __init__(self, session):
70
72
        if not isinstance(session, RPCSession):
71
73
            raise TypeError("RPCSession argument expected, got %s" % type(session))
 
74
        self.socket_timeout = cherrypy.config.get('openerp.server.timeout')
72
75
        self.session = session
73
76
 
74
77
    def __rpc__(self, obj, method, args=(), auth=True):
188
191
        sock = TinySocket()
189
192
        try:
190
193
            sock.connect(self.session.host, self.session.port)
 
194
            sock.sock.settimeout(self.socket_timeout)
191
195
            if auth:
192
196
                args = (self.session.db, self.session.uid, self.session.password) + args
193
197
            sock.send((obj, method) + args)
354
358
        if not self.is_logged():
355
359
            raise NotLoggedIn(_('Not logged...'), _('Authorization Error'))
356
360
 
 
361
        self.socket_timeout = cherrypy.config.get('openerp.server.timeout')
357
362
        return self.gateway.execute(obj, method, *args)
358
363
 
359
364
    def execute_noauth(self, obj, method, *args):
360
365
        return self.gateway.execute_noauth(obj, method, *args)
361
366
 
362
367
    def execute_db(self, method, *args):
 
368
        self.gateway.socket_timeout = cherrypy.config.get('openerp.server.timeout') * 10
 
369
        cherrypy.response.timeout = 60000
363
370
        return self.execute_noauth('db', method, *args)
364
371
 
365
372