Skip to content

Commit

Permalink
Fix for ZODB 5: Abort transaction before DB close.
Browse files Browse the repository at this point in the history
  • Loading branch information
jensens committed Apr 7, 2017
1 parent bfd9424 commit f1de157
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
4 changes: 3 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ New features:

Bug fixes:

- *add item here*
- Fix for ZODB 5: Abort transaction before DB close.
[jensens, jimfulton, ale-rt]



4.3.0 (2017-03-05)
Expand Down
15 changes: 6 additions & 9 deletions src/plone/testing/z2.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
from Zope2.App.schema import Zope2VocabularyRegistry
from ZPublisher import publish_module
from ZServer import PubCore

import contextlib
import os
import transaction

try:
from plone.testing._z2_testbrowser import Browser
Expand Down Expand Up @@ -264,9 +266,7 @@ def zopeApp(db=None, connection=None, environ=None):
pass an open connection as ``connection`` (the connection will not be
closed).
"""

import Zope2
import transaction

closeConn = True
if connection is not None:
Expand Down Expand Up @@ -303,10 +303,10 @@ def zopeApp(db=None, connection=None, environ=None):
finally:
try:
app.REQUEST.close()

if closeConn:
transaction.abort()
connection.close()
except:
except Exception:
if inner_exception:
raise inner_exception
else:
Expand Down Expand Up @@ -603,6 +603,7 @@ def tearDownDatabase(self):
del self._dbtab

# Close and pop the zodbDB resource
transaction.abort()
self['zodbDB'].close()
del self['zodbDB']

Expand Down Expand Up @@ -752,6 +753,7 @@ def tearDownFive(self):

setVocabularyRegistry(self._oldVocabularyRegistry)


STARTUP = Startup()


Expand Down Expand Up @@ -788,7 +790,6 @@ class MyFixture(Layer):

def testSetUp(self):
import Zope2
import transaction

# Open a new app and save it as the resource ``app``.

Expand Down Expand Up @@ -816,7 +817,6 @@ def testSetUp(self):
self['request'] = request

def testTearDown(self):
import transaction

# Abort the transaction
transaction.abort()
Expand Down Expand Up @@ -870,7 +870,6 @@ class MyFixture(Layer):

def testSetUp(self):
import Zope2
import transaction

# Override zodbDB from the layer setup. Since it was set up by
# this layer, we can't just assign a new shadow. We therefore keep
Expand Down Expand Up @@ -906,8 +905,6 @@ def testSetUp(self):
self['request'] = request

def testTearDown(self):
import transaction

# Abort any open transactions
transaction.abort()

Expand Down

0 comments on commit f1de157

Please sign in to comment.