<div><br></div><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Nope. This is a bug.</blockquote>
</div><div><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Really, ``begin` and ``abort`` are equivalent.  It might be better if<br>


there wasn&#39;t a ``begin`` method, as it&#39;s missleading. One should be an<br>alias for the other. I&#39;d be for deprecating ``begin``. The call to<br>``_new_transaction`` should be moved to the point in ``get`` where a<br>


new transaction is created, and ``begin`` should be made an alias for<br>``abort``.</blockquote></div><div><br></div><div><br></div>Makes sense. I&#39;ve created a bug report on launchpad here:<div><br></div><div><a href="https://bugs.launchpad.net/zodb/+bug/1153116" target="_blank">https://bugs.launchpad.net/zodb/+bug/1153116</a></div>


<div><br></div><div>Let me know if that&#39;s good or if there&#39;s somewhere else I&#39;d need to report it. Any idea when there would be a fix?</div><div><br></div><div><br></div><div><div><br><div class="gmail_quote">


On Sat, Mar 9, 2013 at 5:50 AM, Jim Fulton <span dir="ltr">&lt;<a href="mailto:jim@zope.com" target="_blank">jim@zope.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<div>On Fri, Mar 8, 2013 at 9:54 PM, Siddhartha Kasivajhula<br>
&lt;<a href="mailto:CountVajhula@gmail.com" target="_blank">CountVajhula@gmail.com</a>&gt; wrote:<br>
&gt; Hi there,<br>
&gt; I&#39;ve been discussing this issue with Laurence Rowe on the pylons-dev mailing<br>
&gt; list, and he suggested bringing it up here.<br>
&gt;<br>
&gt; I&#39;m writing a MongoDB data manager for the python transaction package:<br>
&gt; <a href="https://github.com/countvajhula/mongomorphism" target="_blank">https://github.com/countvajhula/mongomorphism</a><br>
&gt; I noticed that for a synchronizer, the beforeCompletion() and<br>
&gt; afterCompletion() methods are always called once the synch has been<br>
&gt; registered, but the newTransaction() method is only called when an explicit<br>
&gt; call to transaction.begin() is made. Since it&#39;s possible for transactions to<br>
&gt; be started without this explicit call, I was wondering if there was a good<br>
&gt; reason why these two cases (explicitly vs implicitly begun transactions)<br>
&gt; would be treated differently.<br>
<br>
</div>Nope. This is a bug.<br>
<div><br>
&gt; That is, should the following two cases not be<br>
&gt; equivalent, and therefore should the newTransaction() method be called in<br>
&gt; both cases:<br>
&gt;<br>
&gt; (1)<br>
&gt; t = transaction.get()<br>
&gt; t.join(my_dm)<br>
&gt; ..some changes to the data..<br>
&gt; transaction.commit()<br>
&gt;<br>
&gt; and:<br>
&gt;<br>
&gt; (2)<br>
&gt; transaction.begin()<br>
&gt; t = transaction.get()<br>
&gt; t.join(my_dm)<br>
&gt; ..some changes to the data..<br>
&gt; transaction.commit()<br>
<br>
</div>Only if (1) was was preceded by an ``abort``. The definition of<br>
``get`` is to get the current transaction, creating one, if necessary.<br>
<br>
Really, ``begin` and ``abort`` are equivalent.  It might be better if<br>
there wasn&#39;t a ``begin`` method, as it&#39;s missleading. One should be an<br>
alias for the other. I&#39;d be for deprecating ``begin``. The call to<br>
``_new_transaction`` should be moved to the point in ``get`` where a<br>
new transaction is created, and ``begin`` should be made an alias for<br>
``abort``.<br>
<div><br>
<br>
&gt; In my mongo dm implementation, I am using the synchronizer to do some<br>
&gt; initialization before each transaction gets underway, and am currently<br>
&gt; requiring explicit calls to transaction.begin() at the start of each<br>
&gt; transaction. Unfortunately, it appears that other third party libraries<br>
&gt; using the transaction library may not be calling begin() explicitly, and in<br>
&gt; particular my data manager doesn&#39;t work when used with pyramid_tm.<br>
&gt;<br>
&gt; Another thing I noticed was that a synchronizer cannot be registered like<br>
&gt; so:<br>
&gt; transaction.manager.registerSynch(MySynch())<br>
&gt; .. and can only be registered like this:<br>
&gt; synch = MySynch()<br>
&gt; transaction.manager.registerSynch(synch)<br>
&gt;<br>
&gt; ... which I&#39;m told is due to MySynch() being stored in a &quot;WeakSet&quot; which<br>
&gt; means it gets garbage collected. Currently this means that I&#39;m retaining a<br>
&gt; reference to the synch as a global that I never use. Just seems a bit<br>
&gt; contrived so thought I&#39;d mention that as well, in case there&#39;s anything that<br>
&gt; can be done about that.<br>
<br>
</div>This is to prevent memory leaks.  Normally, the synchronizier is<br>
associated with a database. For example, the synchronizers are<br>
database connection methods.  A stand-alone synchronizer seems weird<br>
to me.<br>
<br>
Jim<br>
<br>
--<br>
Jim Fulton<br>
<a href="http://www.linkedin.com/in/jimfulton" target="_blank">http://www.linkedin.com/in/jimfulton</a><br>
Jerky is better than bacon! <a href="http://zo.pe/Kqm" target="_blank">http://zo.pe/Kqm</a><br>
</blockquote></div><br></div></div>