Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/63.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Preserve ZCA site for transaction hooks that depend on it.
22 changes: 11 additions & 11 deletions src/plone/app/testing/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,18 +256,19 @@ def ploneSite(db=None, connection=None, environ=None, flavour=zope):
setHooks()
site = getSite()

with getattr(flavour, 'zopeApp')(db, connection, environ) as app:
portal = app[PLONE_SITE_ID]
try:
with getattr(flavour, 'zopeApp')(db, connection, environ) as app:
portal = app[PLONE_SITE_ID]

setSite(portal)
login(portal, TEST_USER_NAME)
setSite(portal)
login(portal, TEST_USER_NAME)

try:
yield portal
finally:
logout()
if site is not portal:
setSite(site)
try:
yield portal
finally:
logout()
finally:
setSite(site)


# Layer base class
Expand Down Expand Up @@ -379,7 +380,6 @@ def setUp(self):
# Allow subclass to configure a persistent fixture
setSite(portal)
self.setUpPloneSite(portal)
setSite(None)

# Keep track of PAS plugins that were added during setup
self.snapshotMultiPlugins(preSetupMultiPlugins)
Expand Down