Commit fd033a70 authored by Jérome Perrin's avatar Jérome Perrin

ERP5Type: xxx wip on publish

parent 189316b2
...@@ -601,17 +601,30 @@ class ERP5TypeTestCaseMixin(ProcessingNodeTestCase, PortalTestCase): ...@@ -601,17 +601,30 @@ class ERP5TypeTestCaseMixin(ProcessingNodeTestCase, PortalTestCase):
def publish(self, path, basic=None, env=None, extra=None, def publish(self, path, basic=None, env=None, extra=None,
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.
This was copied from Zope.Testing.ZopeTestCase.functional and adjusted to:
* fix a problem with some passwords ( d8e87e7ab922cab4486a715e0a8ed2530c696cae )
* set HTTP_ACCEPT_CHARSET
* support live tests hacks
'''
from ZPublisher.Response import Response from ZPublisher.Response import Response
from ZPublisher.Test import publish_module from ZPublisher.Test import publish_module
from AccessControl.SecurityManagement import getSecurityManager from AccessControl.SecurityManagement import getSecurityManager
from AccessControl.SecurityManagement import setSecurityManager from AccessControl.SecurityManagement import setSecurityManager
from zope.security.management import endInteraction
from zope.security.management import restoreInteraction
request = self.app.REQUEST
# Save current security manager # Save current security manager
sm = getSecurityManager() sm = getSecurityManager()
#endInteraction()
_module_cache_set = getattr(request, '_module_cache_set', None)
try:
# Commit the sandbox for good measure # Commit the sandbox for good measure
self.commit() self.commit()
...@@ -620,8 +633,6 @@ class ERP5TypeTestCaseMixin(ProcessingNodeTestCase, PortalTestCase): ...@@ -620,8 +633,6 @@ class ERP5TypeTestCaseMixin(ProcessingNodeTestCase, PortalTestCase):
if extra is None: if extra is None:
extra = {} extra = {}
request = self.app.REQUEST
env['SERVER_NAME'] = request['SERVER_NAME'] env['SERVER_NAME'] = request['SERVER_NAME']
env['SERVER_PORT'] = request['SERVER_PORT'] env['SERVER_PORT'] = request['SERVER_PORT']
env['HTTP_ACCEPT_CHARSET'] = request['HTTP_ACCEPT_CHARSET'] env['HTTP_ACCEPT_CHARSET'] = request['HTTP_ACCEPT_CHARSET']
...@@ -652,10 +663,15 @@ class ERP5TypeTestCaseMixin(ProcessingNodeTestCase, PortalTestCase): ...@@ -652,10 +663,15 @@ class ERP5TypeTestCaseMixin(ProcessingNodeTestCase, PortalTestCase):
debug=not handle_errors, debug=not handle_errors,
) )
return ResponseWrapper(response, outstream, path)
finally:
# Restore security manager # Restore security manager
setSecurityManager(sm) setSecurityManager(sm)
#restoreInteraction()
if _module_cache_set is not None:
print "bah ouais", _module_cache_set
request._module_cache_set = _module_cache_set
return ResponseWrapper(response, outstream, path)
def getConsistencyMessageList(self, obj): def getConsistencyMessageList(self, obj):
return sorted([ str(message.getMessage()) return sorted([ str(message.getMessage())
......
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