# HG changeset patch # User Philippe Pepiot # Date 1553699990 -3600 # Node ID 71aa20cb43f239e3221be9d9aa811a7d5fe81e1e # Parent 85194bd4911945f741f119740c7cc272039444f9 [cwconfig] drop legacy cube importer We don't want to support legacy cubes anymore. diff -r 85194bd49119 -r 71aa20cb43f2 cubicweb/__init__.py --- a/cubicweb/__init__.py Fri Mar 22 17:42:36 2019 +0100 +++ b/cubicweb/__init__.py Wed Mar 27 16:19:50 2019 +0100 @@ -20,12 +20,10 @@ """ -import imp import logging import os import pickle import sys -import types import warnings import zlib @@ -268,60 +266,3 @@ not be processed, a memory allocation error occurred during processing, etc. """ - - -# Import hook for "legacy" cubes ############################################## - -class _CubesLoader(object): - - def __init__(self, *modinfo): - self.modinfo = modinfo - - def load_module(self, fullname): - try: - # If there is an existing module object named 'fullname' in - # sys.modules , the loader must use that existing module. - # Otherwise, the reload() builtin will not work correctly. - return sys.modules[fullname] - except KeyError: - pass - if fullname == 'cubes': - mod = sys.modules[fullname] = types.ModuleType( - fullname, doc='CubicWeb cubes') - else: - modname, file, pathname, description = self.modinfo - try: - mod = sys.modules[fullname] = imp.load_module( - modname, file, pathname, description) - finally: - # https://docs.python.org/2/library/imp.html#imp.load_module - # Important: the caller is responsible for closing the file - # argument, if it was not None, even when an exception is - # raised. This is best done using a try ... finally statement - if file is not None: - file.close() - return mod - - -class _CubesImporter(object): - """Module finder handling redirection of import of "cubes." - to "cubicweb_". - """ - - @classmethod - def install(cls): - if not any(isinstance(x, cls) for x in sys.meta_path): - self = cls() - sys.meta_path.append(self) - - def find_module(self, fullname, path=None): - if fullname == 'cubes': - return _CubesLoader() - elif fullname.startswith('cubes.') and fullname.count('.') == 1: - modname = 'cubicweb_' + fullname.split('.', 1)[1] - try: - modinfo = imp.find_module(modname) - except ImportError: - return None - else: - return _CubesLoader(modname, *modinfo) diff -r 85194bd49119 -r 71aa20cb43f2 cubicweb/cwconfig.py --- a/cubicweb/cwconfig.py Fri Mar 22 17:42:36 2019 +0100 +++ b/cubicweb/cwconfig.py Wed Mar 27 16:19:50 2019 +0100 @@ -663,8 +663,6 @@ @classmethod def cls_adjust_sys_path(cls): """update python path if necessary""" - from cubicweb import _CubesImporter - _CubesImporter.install() import cubes cubes.__path__ = cls.cubes_search_path()