Skip to content

Commit

Permalink
Repair code trying to start a new transaction.
Browse files Browse the repository at this point in the history
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()
  • Loading branch information
Tim Peters committed Sep 16, 2004
1 parent ebbe75e commit bb5ad4f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions zopepublication.py
Expand Up @@ -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
Expand Down Expand Up @@ -77,7 +78,7 @@ def beforeTraversal(self, request):

request.setPrincipal(p)
newInteraction(request)
get_transaction().begin()
transaction.begin()

def _maybePlacefullyAuthenticate(self, request, ob):
if not IUnauthenticatedPrincipal.providedBy(request.principal):
Expand Down Expand Up @@ -346,8 +347,7 @@ def handleException(self, object, request, exc_info, retry_allowed=True):
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
Expand Down

0 comments on commit bb5ad4f

Please sign in to comment.