Commit 4de58db3 authored by Vincent Pelletier's avatar Vincent Pelletier

Factorise local_var access.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2472 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent d5dc467f
...@@ -863,20 +863,21 @@ class Application(object): ...@@ -863,20 +863,21 @@ class Application(object):
@profiler_decorator @profiler_decorator
def tpc_finish(self, transaction, tryToResolveConflict, f=None): def tpc_finish(self, transaction, tryToResolveConflict, f=None):
"""Finish current transaction.""" """Finish current transaction."""
if self.local_var.txn is not transaction: local_var = self.local_var
if local_var.txn is not transaction:
raise StorageTransactionError('tpc_finish called for wrong ' raise StorageTransactionError('tpc_finish called for wrong '
'transaction') 'transaction')
if not self.local_var.txn_voted: if not local_var.txn_voted:
self.tpc_vote(transaction, tryToResolveConflict) self.tpc_vote(transaction, tryToResolveConflict)
self._load_lock_acquire() self._load_lock_acquire()
try: try:
tid = self.local_var.tid tid = local_var.tid
# Call function given by ZODB # Call function given by ZODB
if f is not None: if f is not None:
f(tid) f(tid)
# Call finish on master # Call finish on master
oid_list = self.local_var.data_list oid_list = local_var.data_list
p = Packets.AskFinishTransaction(tid, oid_list) p = Packets.AskFinishTransaction(tid, oid_list)
self._askPrimary(p) self._askPrimary(p)
...@@ -887,7 +888,7 @@ class Application(object): ...@@ -887,7 +888,7 @@ class Application(object):
self._cache_lock_acquire() self._cache_lock_acquire()
try: try:
mq_cache = self.mq_cache mq_cache = self.mq_cache
for oid, data in self.local_var.data_dict.iteritems(): for oid, data in local_var.data_dict.iteritems():
if data == '': if data == '':
if oid in mq_cache: if oid in mq_cache:
del mq_cache[oid] del mq_cache[oid]
...@@ -895,7 +896,7 @@ class Application(object): ...@@ -895,7 +896,7 @@ class Application(object):
mq_cache[oid] = tid, data mq_cache[oid] = tid, data
finally: finally:
self._cache_lock_release() self._cache_lock_release()
self.local_var.clear() local_var.clear()
return tid return tid
finally: finally:
self._load_lock_release() self._load_lock_release()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment