Hi there,
I've been discussing this issue with Laurence Rowe on the pylons-dev
mailing list, and he suggested bringing it up here.

I'm writing a MongoDB data manager for the python transaction package:
I noticed that for a synchronizer, the beforeCompletion() and
afterCompletion() methods are always called once the synch has been
registered, but the newTransaction() method is only called when an explicit
call to transaction.begin() is made. Since it's possible for transactions
to be started without this explicit call, I was wondering if there was a
good reason why these two cases (explicitly vs implicitly begun
transactions) would be treated differently. That is, should the following
two cases not be equivalent, and therefore should the newTransaction()
method be called in both cases:

t = transaction.get()
..some changes to the data..


t = transaction.get()
..some changes to the data..

In my mongo dm implementation, I am using the synchronizer to do some
initialization before each transaction gets underway, and am currently
requiring explicit calls to transaction.begin() at the start of each
transaction. Unfortunately, it appears that other third party libraries
using the transaction library may not be calling begin() explicitly, and in
particular my data manager doesn't work when used with pyramid_tm.

Another thing I noticed was that a synchronizer cannot be registered like
.. and can only be registered like this:
synch = MySynch()

... which I'm told is due to MySynch() being stored in a "WeakSet" which
means it gets garbage collected. Currently this means that I'm retaining a
reference to the synch as a global that I never use. Just seems a bit
contrived so thought I'd mention that as well, in case there's anything
that can be done about that.

Any thoughts?

For more information about ZODB, see http://zodb.org/

ZODB-Dev mailing list  -  ZODB-Dev@zope.org

Reply via email to