[ZODB-Dev] preventing a transaction from committing within appcode
Jeremy Hylton
jhylton at gmail.com
Wed Sep 8 15:41:27 EDT 2004
On Wed, 8 Sep 2004 15:02:16 -0400, Tim Peters <tim at zope.com> wrote:
> Well, there isn't an explicit "transaction manager" concept in 3.2; the
> default policy is implemented via the stuff rammed into __builtin__, and
> another policy implemented via Connection.setLocalTransaction(). I suppose
> you could replace __builtin__.get_transaction after ZODB.Transaction.py
> creates it. The implementation of get_transaction() in Transaction.py
> always returns a Transaction object, and cannot be tricked into refusing to
> do so:
>
> def get_transaction(_id=thread.get_ident, _t=_t, get=_t.get):
> id = _id()
> t = get(id, None)
> if t is None:
> _t[id] = t = Transaction(id)
> return t
>
> Perhaps ugly-enough code could reach into Transaction._t and replace
> _t[thread.get_ident()], upon an abort(), with an instance of a new
> Transaction subclass whose commit() method refused to do anything.
You could get rid of the "if t is None:" clause and add some other way
to create a new entry in _t. Then you'd need to change the client
code to explicitly create transactions.
Jeremy
More information about the ZODB-Dev
mailing list