Commit 56692de5 authored by Wichert Akkerman's avatar Wichert Akkerman

Set and restore the site for functional tests as well. Forward port from 2.10 branch

parent a581a35f
......@@ -39,6 +39,7 @@ class Functional(sandbox.Sandboxed):
request_method='GET', stdin=None, handle_errors=True):
'''Publishes the object at 'path' returning a response object.'''
from zope.app.component.hooks import setSite, getSite
from StringIO import StringIO
from ZPublisher.Response import Response
from ZPublisher.Test import publish_module
......@@ -49,6 +50,10 @@ class Functional(sandbox.Sandboxed):
# Save current security manager
sm = getSecurityManager()
# And we need to store the old site
old_site = getSite()
setSite(None)
# Commit the sandbox for good measure
transaction.commit()
......@@ -91,6 +96,9 @@ class Functional(sandbox.Sandboxed):
# Restore security manager
setSecurityManager(sm)
# And we need to restore the site again
setSite(old_site)
return ResponseWrapper(response, outstream, path)
......
......@@ -117,6 +117,7 @@ def http(request_string, handle_errors=True):
"""
import urllib
import rfc822
from zope.app.component.hooks import setSite, getSite
from cStringIO import StringIO
from ZPublisher.Response import Response
from ZPublisher.Test import publish_module
......@@ -126,6 +127,10 @@ def http(request_string, handle_errors=True):
# Save current Security Manager
old_sm = getSecurityManager()
# And we need to store the old site
old_site = getSite()
setSite(None)
# Commit work done by previous python code.
transaction.commit()
......@@ -193,7 +198,10 @@ def http(request_string, handle_errors=True):
# by calling the publish method above
setSecurityManager(old_sm)
# And we need to restore the site again
setSite(old_site)
# Sync connection
sync()
return DocResponseWrapper(response, outstream, path, header_output)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment