# HG changeset patch # User Pierre-Yves David # Date 1363974663 -3600 # Node ID 0144b26e958d54a5995e86b63cb746ee6dffd6a1 # Parent 6b397a0ba1d6723512b24c7673177e54e8c6f9b8 [transaction] handle ``mode`` default value in Transaction The transaction mode is now explicitly passed at creation time and always read from the Transaction object. Note that there is a slight behavior change. The transaction mode is now set at the creation of the transaction. Changes made to the default value have no longer any effect on existing transaction. diff -r 6b397a0ba1d6 -r 0144b26e958d server/session.py --- a/server/session.py Fri Mar 22 17:47:45 2013 +0100 +++ b/server/session.py Fri Mar 22 18:51:03 2013 +0100 @@ -161,14 +161,14 @@ transaction, with or without writing) """ - def __init__(self, txid): + def __init__(self, txid, mode='read'): #: transaction unique id self.transactionid = txid #: reentrance handling self.ctx_count = 0 #: connection handling mode - self.mode = None + self.mode = mode #: connection set used to execute queries on sources self.cnxset = None @@ -342,7 +342,8 @@ try: self.__threaddata.txdata = self._tx_data[txid] except KeyError: - self.__threaddata.txdata = self._tx_data[txid] = Transaction(txid) + tx = Transaction(txid, self.default_mode) + self.__threaddata.txdata = self._tx_data[txid] = tx @property def _threaddata(self): @@ -784,7 +785,7 @@ self.default_mode = 'read' def get_mode(self): - return getattr(self._threaddata, 'mode', self.default_mode) + return self._threaddata.mode def set_mode(self, value): self._threaddata.mode = value mode = property(get_mode, set_mode,