Commit 6102ed47 authored by Jérome Perrin's avatar Jérome Perrin

ProcessingNodeTestCase: also setRequest in timerserver loop

This is similar to 18deb716 (ProcessingNodeTestCase: also setRequest
in processing_node, 2023-05-02), as said in that commit message,
timerserver loop calls setRequest, but before entering the loop, we
wait for the portal to be created with:

 447   │           try:
 448   │             self.portal = self.app[self.app.test_portal_name]
 449   │           except (AttributeError, KeyError):
 450   │             continue

While accessing like this, this will load classes and initialize dynamic
modules, on python2 this was OK, but on python3 this was raising an
error because `getRequest` returned None:

  File "./parts/erp5/product/ERP5Type/dynamic/component_package.py", line 449, in load_module
    return self.__load_module(fullname)
  File "./parts/erp5/product/ERP5Type/dynamic/component_package.py", line 416, in __load_module
    erp5.component.ref_manager.add_module(module)
  File "./parts/erp5/product/ERP5Type/dynamic/dynamic_module.py", line 86, in add_module
    self.add_request(get_request())
  File "./parts/erp5/product/ERP5Type/dynamic/dynamic_module.py", line 64, in add_request
    self.setdefault(last_sync, (WeakSet(), set()))[0].add(request_obj)
  File "./lib/python3.9/_weakrefset.py", line 89, in add
    self.data.add(ref(item, self._remove))
TypeError: cannot create weak reference to 'NoneType' object

On python2, this was actually raising as well, but this error is hidden
by a `hasattr`, because on python2 `hasattr` ignores all exceptions and
on python3 it only ignores only `AttributeError`.

  File "./parts/erp5/product/ERP5Type/Core/PropertySheet.py", line 61, in createAccessorHolder
    self.applyOnAccessorHolder(accessor_holder, expression_context, portal)
  File "./parts/erp5/product/ERP5Type/Core/PropertySheet.py", line 175, in applyOnAccessorHolder
    for property_definition in self.contentValues():
  File "./parts/erp5/product/ERP5Type/Core/Folder.py", line 1570, in contentValues
    portal_type_id_list = self._getTypesTool().listContentTypes()
  File "./parts/erp5/product/ERP5Type/Tool/TypesTool.py", line 173, in listContentTypes
    provider_value = _getOb(provider, None)
  File "./eggs/Zope-4.8.7-py2.7.egg/OFS/ObjectManager.py", line 323, in _getOb
    if id[:1] != '_' and hasattr(aq_base(self), id):
  File "./parts/erp5/product/ERP5Type/dynamic/lazy_class.py", line 120, in __getattribute__
    self.__class__.loadClass()
parent 8eefc051
...@@ -407,6 +407,7 @@ class ProcessingNodeTestCase(ZopeTestCase.TestCase): ...@@ -407,6 +407,7 @@ class ProcessingNodeTestCase(ZopeTestCase.TestCase):
"""Main loop using timer server. """Main loop using timer server.
""" """
import Products.TimerService import Products.TimerService
setRequest(self.app.REQUEST)
# AlarmTool uses alarmNode='' as a way to bootstrap an alarm node, but # AlarmTool uses alarmNode='' as a way to bootstrap an alarm node, but
# during these tests we don't want the first node to start executing # during these tests we don't want the first node to start executing
......
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