[ZODB-Dev] proposal about setLocalTransaction

Adam Groszer adamg@mailbox.hu
Tue Apr 15 08:34:23 EDT 2003


Dear All,

I'd like to make a proposal about setLocalTransaction.
Mostly because I tried Dieter's ReadCommitted.pat. It requires a transaction
in Connection._setDB and it was impossible to set the transaction mode
before db.open. I think it would be nice to somehow preset the transaction
mode in the Connection class or subclass.

Comments are welcome,

Adam


The following listing is based on 3.2a1
Connection.py:

class Connection(ExportImport.ExportImport):
[snip]
    _code_timestamp = 0
    _transaction = None

    #to easily set default transaction mode
    _local_trans_mode = 0

[snip]

    def __init__(self, version='', cache_size=400,
                 cache_deactivate_after=60):
        """Create a new Connection"""
[snip]
        self._store_count = 0  # Number of objects stored

        self.setLocalTransaction(self._local_trans_mode)

    def getTrans_loc(self):
        if self._transaction is None:
            self._transaction = Transaction()
        return self._transaction

    def getTrans_thr(self):
        return get_transaction()

    def setLocalTransaction(self, flag=1):
        """Use a transaction bound to the connection rather than the
thread"""
        self._local_trans_mode = flag

        if flag:
            self.getTransaction = self.getTrans_loc
        else:
            self.getTransaction = self.getTrans_thr

            self._transaction = None
        return self.getTransaction()
[snip]





More information about the ZODB-Dev mailing list