[ZODB-Dev] simple example of undo( )
Jeremy Hylton
jeremy@alum.mit.edu
Mon, 23 Sep 2002 21:54:42 -0400
>>>>> "CR" == Christian Reis <kiko@async.com.br> writes:
CR> Let's say you modified 5 objects in the last transaction. The
CR> problem with sync(), specially in a system like ours, in which
CR> many parts of the UI may have objects that have been modified
CR> (but not committed, as nobody has had the guts to click on "OK"
CR> yet). So calling abort()/sync() can undo things beyond what's
CR> desired.
I don't think I understand. sync() only affects the current thread.
In the example that started this, an undo transaction was committed.
This commit, unlike almost any other commit, will not also sync the
current connection.
Remember, I'm recommending to call sync() immediately after a
transaction commit.
>> >> The sync() method makes this happen explicitly, but I wonder
>> >> why there isn't some other implicit mechanism.
>>
CR> Can we send per-instance invalidation messages? If we can't,
CR> then I surmise that may be the reason why it's not done
CR> implicitly.
>>
>> How would you know what objects to invalidate?
CR> That's a good point. So transactions are atomic in the sense
CR> that a per-instance rollback/undo isn't really possible? The
CR> transaction *does* know what instances have been changed,
CR> though, doesn't it?
Yes to both questions. A transaction is an all or nothing affair.
Think about the classic banking example. Would you want to undo half
of the account transfer transaction? You can't guarantee consistency
unless you respect transaction boundaries.
Jeremy