diff --git a/product/ERP5Type/__init__.py b/product/ERP5Type/__init__.py index 63c14d580e82465e513e53c27904a746786336ac..8713d72932861aace831ba9c103cdbf0181a2f45 100644 --- a/product/ERP5Type/__init__.py +++ b/product/ERP5Type/__init__.py @@ -33,6 +33,11 @@ from __future__ import absolute_import from App.config import getConfiguration from .patches import python, globalrequest, Pandas +from App.version_txt import getZopeVersion +if getZopeVersion()[0] == 2: # BBB Zope2 + IS_ZOPE2 = True +else: + IS_ZOPE2 = False import six if six.PY2: from .patches import pylint @@ -45,12 +50,6 @@ if six.PY3: else: WITH_LEGACY_WORKFLOW = True -from App.version_txt import getZopeVersion -if getZopeVersion()[0] == 2: # BBB Zope2 - IS_ZOPE2 = True -else: - IS_ZOPE2 = False - # We have a name conflict with source_reference and destination_reference, # which are at the same time property accessors for 'source_reference' # property, and category accessors (similar to getSourceValue().getReference()) diff --git a/product/ERP5Type/patches/pylint.py b/product/ERP5Type/patches/pylint.py index bdbe395c091b22eb45372a0e89b5d0b0d5f68b6c..5fe480b789d912c76b7f93622151ae75ce1c2e88 100644 --- a/product/ERP5Type/patches/pylint.py +++ b/product/ERP5Type/patches/pylint.py @@ -20,6 +20,7 @@ from __future__ import absolute_import import sys +from Products.ERP5Type import IS_ZOPE2 # TODO: make sure that trying to use it does not import isort, because the # latter hacks Python in order to execute: @@ -439,6 +440,25 @@ def fail_hook_BTrees(modname): return astng MANAGER.register_failed_import_hook(fail_hook_BTrees) +if IS_ZOPE2: # BBB Zope2 + # No name 'OOBTree' in module 'BTrees.OOBTree' (no-name-in-module) + # Unable to import 'BTrees.OOBTree' (import-error) + # + # When the corresponding C Extension (BTrees._Foo) is available, update + # BTrees.Foo namespace from the C extension, otherwise use Python definitions + # by dropping the `Py` suffix in BTrees.Foo symbols. + import BTrees + for module_name, module in inspect.getmembers(BTrees, inspect.ismodule): + if module_name[0] != '_': + continue + try: + extended_module = BTrees.__dict__[module_name[1:]] + except KeyError: + continue + else: + _register_module_extender_from_live_module(extended_module.__name__, + module) + # No name 'ElementMaker' in module 'lxml.builder' (no-name-in-module) # # imp.load_dynamic() on .so file