Hi there,<div>I&#39;ve been discussing this issue with Laurence Rowe on the pylons-dev mailing list, and he suggested bringing it up here.<br><div><br></div><div>I&#39;m writing a MongoDB data manager for the python transaction package: <a href="https://github.com/countvajhula/mongomorphism" target="_blank">https://github.com/countvajhula/mongomorphism</a></div>





<div>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&#39;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:</div>





<div><br></div><div>(1)</div><div><font face="courier new, monospace">t = transaction.get()</font></div><div><font face="courier new, monospace">t.join(my_dm)</font></div><div><font face="courier new, monospace">..some changes to the data..</font></div>


<div><font face="courier new, monospace">transaction.commit()</font></div><div><br></div><div>and:</div><div><br></div><div>(2)</div><div><div><font face="courier new, monospace">


transaction.begin()</font></div><div><font face="courier new, monospace">t = transaction.get()</font></div><div><font face="courier new, monospace">t.join(my_dm)</font></div><div><font face="courier new, monospace">..some changes to the data..</font></div>


<div><font face="courier new, monospace">transaction.commit()</font></div></div><div><br></div><div>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&#39;t work when used with pyramid_tm.</div>





<div><br></div><div>Another thing I noticed was that a synchronizer cannot be registered like so:</div><div><font face="courier new, monospace">transaction.manager.registerSynch(MySynch())</font></div><div>.. and can only be registered like this:</div>


<div><font face="courier new, monospace">synch = MySynch()</font></div>


<div><div><font face="courier new, monospace">transaction.manager.registerSynch(synch)</font></div></div><div><br></div><div>... which I&#39;m told is due to MySynch() being stored in a &quot;WeakSet&quot; which means it gets garbage collected. Currently this means that I&#39;m retaining a reference to the synch as a global that I never use. Just seems a bit contrived so thought I&#39;d mention that as well, in case there&#39;s anything that can be done about that.</div>





<div><br></div><div>Any thoughts?</div></div><div><br></div><div>Thanks!</div><div>-Sid</div><div><br></div>