[Zope3-checkins] SVN: Zope3/branches/ZopeX3-3.0/src/zope/app/
Repair code trying to start a new transaction.
Tim Peters
tim.one at comcast.net
Wed Sep 15 20:09:04 EDT 2004
Log message for revision 27542:
Repair code trying to start a new transaction.
Never do these in ZODB 3:3:
get_transaction().begin()
some_txn_object.begin()
They raise DeprecationWarning, and don't do exactly what they
did in ZODB 3.2. Instead do:
import transaction
and then one of these:
transaction.begin()
new_txn_object = transaction.begin()
Changed:
U Zope3/branches/ZopeX3-3.0/src/zope/app/generations/generations.py
U Zope3/branches/ZopeX3-3.0/src/zope/app/publication/zopepublication.py
U Zope3/branches/ZopeX3-3.0/src/zope/app/rdb/tests/test_zopeconnection.py
-=-
Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/generations/generations.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/generations/generations.py 2004-09-15 19:11:42 UTC (rev 27541)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/generations/generations.py 2004-09-16 00:09:03 UTC (rev 27542)
@@ -22,6 +22,7 @@
import logging
import os
import zope.interface
+import transaction
generations_key = 'zope.app.generations'
@@ -333,7 +334,7 @@
while generation < target:
generation += 1
try:
- get_transaction().begin()
+ transaction.begin()
manager.evolve(context, generation)
generations[key] = generation
get_transaction().commit()
Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/publication/zopepublication.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/publication/zopepublication.py 2004-09-15 19:11:42 UTC (rev 27541)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/publication/zopepublication.py 2004-09-16 00:09:03 UTC (rev 27542)
@@ -22,6 +22,7 @@
from new import instancemethod
from ZODB.POSException import ConflictError
+import transaction
from zope.event import notify
from zope.security.interfaces import Unauthorized
@@ -77,7 +78,7 @@
request.setPrincipal(p)
newInteraction(request)
- get_transaction().begin()
+ transaction.begin()
def _maybePlacefullyAuthenticate(self, request, ob):
if not IUnauthenticatedPrincipal.providedBy(request.principal):
@@ -346,8 +347,7 @@
get_transaction().abort()
def beginErrorHandlingTransaction(self, request, ob, note):
- txn = get_transaction()
- txn.begin()
+ txn = transaction.begin()
txn.note(note)
self.annotateTransaction(txn, request, ob)
return txn
Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/rdb/tests/test_zopeconnection.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/rdb/tests/test_zopeconnection.py 2004-09-15 19:11:42 UTC (rev 27541)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/rdb/tests/test_zopeconnection.py 2004-09-16 00:09:03 UTC (rev 27542)
@@ -41,7 +41,7 @@
self.assertEqual(len(transaction.get_transaction()._resources), 1)
def test_commit(self):
- transaction.get_transaction().begin()
+ transaction.begin()
zc = ZopeConnection(ConnectionStub(), TypeInfoStub())
self._txn_registered = True
zc.commit()
More information about the Zope3-Checkins
mailing list