# HG changeset patch # User Philippe Pepiot # Date 1535123942 -7200 # Node ID 7e670235174f1aedba0e5fadb3831d7a85eab918 # Parent 6bcdd7278f7f7ef9e5332224e32497bdabec9df9 Fix possible double import of cubes For a new-style cube, if we import "cubicweb_" and then import "cubes.", the cube will be imported twice. cubes. and then cubicweb_name is ok though... When using pyramid, we try to find which cube define a "includeme" by importing them with the name "cubes.", so we (possibly ?) double import all new-style cube. This case may also occur in tests with PyramidCWTest. Touching the import loader to fix this scares me, so let's fix this by testing "cubicweb_" *before* "cubes.name" (for old style cubes, importing cubicweb_ raise ImportError). diff -r 6bcdd7278f7f -r 7e670235174f cubicweb/pyramid/core.py --- a/cubicweb/pyramid/core.py Wed Aug 22 16:04:39 2018 +0200 +++ b/cubicweb/pyramid/core.py Fri Aug 24 17:19:02 2018 +0200 @@ -413,8 +413,12 @@ cwcfg = config.registry['cubicweb.config'] for cube in cwcfg.cubes(): - pkgname = 'cubes.' + cube - mod = __import__(pkgname) - mod = getattr(mod, cube) + try: + pkgname = 'cubicweb_{}'.format(cube) + mod = __import__(pkgname) + except ImportError: + pkgname = 'cubes.{}'.format(cube) + mod = __import__(pkgname) + mod = getattr(mod, cube) if hasattr(mod, 'includeme'): - config.include('cubes.' + cube) + config.include(pkgname)