Please review this at http://codereview.appspot.com/3731043/
Affected files:
M tryton/common/common.py
M tryton/gui/window/view_form/model/record.py
Index: tryton/common/common.py
===================================================================
--- a/tryton/common/common.py
+++ b/tryton/common/common.py
@@ -32,6 +32,7 @@
except ImportError:
ssl = None
import dis
+from threading import Lock
_ = gettext.gettext
@@ -802,6 +803,8 @@
parent, context, ['form', 'tree'])
return False
+PLOCK = Lock()
+
def process_exception(exception, parent, *args):
global _USERNAME, _DATABASE, _SOCK
if str(exception.args[0]) == 'BadFingerprint':
@@ -816,28 +819,33 @@
message(_('Connection error!\n' \
'Unable to connect to the server!'), parent)
return False
+ if not PLOCK.acquire(False):
+ return False
hostname = rpc._SOCK.hostname
port = rpc._SOCK.port
- while True:
- password = ask(_('Password:'), parent, visibility=False)
- if password is None:
- raise Exception('NotLogged')
- res = rpc.login(rpc._USERNAME, password, hostname, port,
- rpc._DATABASE)
- from tryton.gui.main import Main
- Main.get_main().refresh_ssl()
- if res == -1:
- message(_('Connection error!\n' \
- 'Unable to connect to the server!'), parent)
- return False
- if res < 0:
- continue
- if args:
- try:
- return rpc.execute(*args)
- except Exception, exception:
- return process_exception(exception, parent, *args)
- return True
+ try:
+ while True:
+ password = ask(_('Password:'), parent, visibility=False)
+ if password is None:
+ raise Exception('NotLogged')
+ res = rpc.login(rpc._USERNAME, password, hostname, port,
+ rpc._DATABASE)
+ from tryton.gui.main import Main
+ Main.get_main().refresh_ssl()
+ if res == -1:
+ message(_('Connection error!\n' \
+ 'Unable to connect to the server!'), parent)
+ return False
+ if res < 0:
+ continue
+ if args:
+ try:
+ return rpc.execute(*args)
+ except Exception, exception:
+ return process_exception(exception, parent, *args)
+ return True
+ finally:
+ PLOCK.release()
if exception.args[0] == 'ConcurrencyException':
if len(args) >= 6:
Index: tryton/gui/window/view_form/model/record.py
===================================================================
--- a/tryton/gui/window/view_form/model/record.py
+++ b/tryton/gui/window/view_form/model/record.py
@@ -102,8 +102,6 @@
except Exception, exception:
values = common.process_exception(exception,
self.window, *args)
if not values:
- log = logging.getLogger('record')
- log.error('%s' % exception.args[-1])
values = [{'id': x} for x in ids]
id2value = dict((value['id'], value) for value in values)
if ids != [self.id]:
--
Cédric Krier
B2CK SPRL
Rue de Rotterdam, 4
4000 Liège
Belgium
Tel: +32 472 54 46 59
Email/Jabber: [email protected]
Website: http://www.b2ck.com/
pgpJMuTvJ1Qps.pgp
Description: PGP signature
