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

Revert "zope4py2: fix usage of _Z2HOST"

This reverts commit 3db20ae6
and commit 948d8b57.

This commit and the fixup were not good, reverting to make a proper
commit
parent 3db20ae6
......@@ -57,7 +57,6 @@ getRequest.__code__ = (lambda: get_request()).__code__
from zope.site.hooks import setSite
from Testing import ZopeTestCase
from Testing.makerequest import makerequest
from Testing.ZopeTestCase import PortalTestCase, user_name
from Products.ERP5Type.Core.Workflow import ValidationFailed
from Products.PythonScripts.PythonScript import PythonScript
......@@ -1033,21 +1032,9 @@ class ERP5TypeCommandLineTestCase(ERP5TypeTestCaseMixin):
def _app(self):
'''Opens a ZODB connection and returns the app object.
We override it so that the request knows about the server we started and
has HTTP_ACCEPT_CHARSET set, to get the zpt unicode conflict resolver to
work properly.
'''
We override it to patch HTTP_ACCEPT_CHARSET into REQUEST to get the zpt
unicode conflict resolver to work properly'''
app = PortalTestCase._app(self)
from Products.ERP5Type.tests.ProcessingNodeTestCase import _server_addr
if _server_addr:
app.REQUEST.close()
host, port = _server_addr
app = makerequest(
aq_base(app),
environ={
'SERVER_NAME': host,
'SERVER_PORT': port,
})
app.REQUEST['HTTP_ACCEPT_CHARSET'] = 'utf-8'
return app
......
......@@ -6,6 +6,11 @@ from UserDict import IterableUserDict
import Lifetime
import transaction
from Testing import ZopeTestCase
try:
from Testing.makerequest import _Z2HOST # XXX only on Zope4
from Testing import makerequest as utils
except: # BBB Zope 2.12
from Testing.ZopeTestCase import utils
from ZODB.POSException import ConflictError
from zLOG import LOG, ERROR
from Products.CMFActivity.Activity.Queue import VALIDATION_ERROR_DELAY
......@@ -14,7 +19,6 @@ from Products.ERP5Type.tests.utils import \
addUserToDeveloperRole, createZServer, DummyMailHostMixin, parseListeningAddress
from Products.CMFActivity.ActivityTool import getCurrentNode
_server_addr = None # (host, port) of the http server if it was started, None otherwise
class DictPersistentWrapper(IterableUserDict, object):
......@@ -150,8 +154,7 @@ class ProcessingNodeTestCase(ZopeTestCase.TestCase):
def startZServer(self, verbose=False):
"""Start HTTP ZServer in background"""
global _server_addr
if _server_addr is None:
if utils._Z2HOST is None:
from Products.ERP5Type.tests.runUnitTest import log_directory
log = os.path.join(log_directory, "Z2.log")
message = "Running %s server at %s:%s\n"
......@@ -193,7 +196,7 @@ class ProcessingNodeTestCase(ZopeTestCase.TestCase):
logger.propagate = False
hs = createServer(app_wrapper(webdav_ports=webdav_ports),
logger, sockets=sockets)
_server_addr = hs.addr
utils._Z2HOST, utils._Z2PORT = hs.addr
t = Thread(target=hs.run)
t.setDaemon(1)
t.start()
......@@ -205,7 +208,7 @@ class ProcessingNodeTestCase(ZopeTestCase.TestCase):
except RuntimeError as e:
ZopeTestCase._print(str(e))
else:
_server_addr = hs.server_name, hs.server_port
utils._Z2HOST, utils._Z2PORT = hs.server_name, hs.server_port
_print(hs)
try:
_print(createZServer(log, zserver_type='webdav'))
......@@ -221,7 +224,7 @@ class ProcessingNodeTestCase(ZopeTestCase.TestCase):
if ActivityTool.currentNode == ActivityTool._server_address:
ActivityTool.currentNode = None
ActivityTool._server_address = None
return _server_addr
return utils._Z2HOST, utils._Z2PORT
def _registerNode(self, distributing, processing):
"""Register node to process and/or distribute activities"""
......@@ -242,7 +245,7 @@ class ProcessingNodeTestCase(ZopeTestCase.TestCase):
@classmethod
def unregisterNode(cls):
if _server_addr is not None:
if utils._Z2HOST is not None:
self = cls('unregisterNode')
self.app = self._app()
self._registerNode(distributing=0, processing=0)
......
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