equal
deleted
inserted
replaced
159 the connections set, it can't be freed before end of the transaction), |
159 the connections set, it can't be freed before end of the transaction), |
160 'transaction' (we want to keep the connections set during all the |
160 'transaction' (we want to keep the connections set during all the |
161 transaction, with or without writing) |
161 transaction, with or without writing) |
162 """ |
162 """ |
163 |
163 |
164 def __init__(self, txid): |
164 def __init__(self, txid, mode='read'): |
165 #: transaction unique id |
165 #: transaction unique id |
166 self.transactionid = txid |
166 self.transactionid = txid |
167 #: reentrance handling |
167 #: reentrance handling |
168 self.ctx_count = 0 |
168 self.ctx_count = 0 |
169 |
169 |
170 #: connection handling mode |
170 #: connection handling mode |
171 self.mode = None |
171 self.mode = mode |
172 #: connection set used to execute queries on sources |
172 #: connection set used to execute queries on sources |
173 self.cnxset = None |
173 self.cnxset = None |
174 |
174 |
175 class Session(RequestSessionBase): |
175 class Session(RequestSessionBase): |
176 """Repository user session |
176 """Repository user session |
340 if txid is None: |
340 if txid is None: |
341 txid = threading.currentThread().getName() |
341 txid = threading.currentThread().getName() |
342 try: |
342 try: |
343 self.__threaddata.txdata = self._tx_data[txid] |
343 self.__threaddata.txdata = self._tx_data[txid] |
344 except KeyError: |
344 except KeyError: |
345 self.__threaddata.txdata = self._tx_data[txid] = Transaction(txid) |
345 tx = Transaction(txid, self.default_mode) |
|
346 self.__threaddata.txdata = self._tx_data[txid] = tx |
346 |
347 |
347 @property |
348 @property |
348 def _threaddata(self): |
349 def _threaddata(self): |
349 try: |
350 try: |
350 return self.__threaddata.txdata |
351 return self.__threaddata.txdata |
782 self.default_mode = 'transaction' |
783 self.default_mode = 'transaction' |
783 else: # mode == 'write' |
784 else: # mode == 'write' |
784 self.default_mode = 'read' |
785 self.default_mode = 'read' |
785 |
786 |
786 def get_mode(self): |
787 def get_mode(self): |
787 return getattr(self._threaddata, 'mode', self.default_mode) |
788 return self._threaddata.mode |
788 def set_mode(self, value): |
789 def set_mode(self, value): |
789 self._threaddata.mode = value |
790 self._threaddata.mode = value |
790 mode = property(get_mode, set_mode, |
791 mode = property(get_mode, set_mode, |
791 doc='transaction mode (read/write/transaction), resetted to' |
792 doc='transaction mode (read/write/transaction), resetted to' |
792 ' default_mode on commit / rollback') |
793 ' default_mode on commit / rollback') |