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): ...@@ -39,6 +39,7 @@ class Functional(sandbox.Sandboxed):
request_method='GET', stdin=None, handle_errors=True): request_method='GET', stdin=None, handle_errors=True):
'''Publishes the object at 'path' returning a response object.''' '''Publishes the object at 'path' returning a response object.'''
from zope.app.component.hooks import setSite, getSite
from StringIO import StringIO from StringIO import StringIO
from ZPublisher.Response import Response from ZPublisher.Response import Response
from ZPublisher.Test import publish_module from ZPublisher.Test import publish_module
...@@ -49,6 +50,10 @@ class Functional(sandbox.Sandboxed): ...@@ -49,6 +50,10 @@ class Functional(sandbox.Sandboxed):
# Save current security manager # Save current security manager
sm = getSecurityManager() sm = getSecurityManager()
# And we need to store the old site
old_site = getSite()
setSite(None)
# Commit the sandbox for good measure # Commit the sandbox for good measure
transaction.commit() transaction.commit()
...@@ -91,6 +96,9 @@ class Functional(sandbox.Sandboxed): ...@@ -91,6 +96,9 @@ class Functional(sandbox.Sandboxed):
# Restore security manager # Restore security manager
setSecurityManager(sm) setSecurityManager(sm)
# And we need to restore the site again
setSite(old_site)
return ResponseWrapper(response, outstream, path) return ResponseWrapper(response, outstream, path)
......
...@@ -117,6 +117,7 @@ def http(request_string, handle_errors=True): ...@@ -117,6 +117,7 @@ def http(request_string, handle_errors=True):
""" """
import urllib import urllib
import rfc822 import rfc822
from zope.app.component.hooks import setSite, getSite
from cStringIO import StringIO from cStringIO import StringIO
from ZPublisher.Response import Response from ZPublisher.Response import Response
from ZPublisher.Test import publish_module from ZPublisher.Test import publish_module
...@@ -126,6 +127,10 @@ def http(request_string, handle_errors=True): ...@@ -126,6 +127,10 @@ def http(request_string, handle_errors=True):
# Save current Security Manager # Save current Security Manager
old_sm = getSecurityManager() old_sm = getSecurityManager()
# And we need to store the old site
old_site = getSite()
setSite(None)
# Commit work done by previous python code. # Commit work done by previous python code.
transaction.commit() transaction.commit()
...@@ -193,7 +198,10 @@ def http(request_string, handle_errors=True): ...@@ -193,7 +198,10 @@ def http(request_string, handle_errors=True):
# by calling the publish method above # by calling the publish method above
setSecurityManager(old_sm) setSecurityManager(old_sm)
# And we need to restore the site again
setSite(old_site)
# Sync connection # Sync connection
sync() sync()
return DocResponseWrapper(response, outstream, path, header_output) 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