Commit 223d4818 authored by Arnaud Fontaine's avatar Arnaud Fontaine

ZODB Components: Alias module was not added to sys.modules if the module it...

ZODB Components: Alias module was not added to sys.modules if the module it points to had already been loaded before.
parent 96851e6a
......@@ -254,6 +254,8 @@ class ComponentDynamicPackage(ModuleType):
raise ImportError("%s: no version of Component %s in Site priority" % \
(fullname, name))
module_fullname_alias = self._namespace + '.' + name
# Check whether this module has already been loaded before for a
# specific version, if so, just add it to the upper level
try:
......@@ -262,10 +264,9 @@ class ComponentDynamicPackage(ModuleType):
pass
else:
setattr(self, name, module)
sys.modules[module_fullname_alias] = module
return module
module_fullname_alias = self._namespace + '.' + name
component = getattr(site.portal_components, component_id)
relative_url = component.getRelativeUrl()
......
......@@ -35,6 +35,7 @@ import shutil
import tempfile
import unittest
import warnings
import sys
import transaction
from persistent import Persistent
......@@ -1524,9 +1525,13 @@ class _TestZodbComponent(SecurityTestCase):
reset_portal_type_at_transaction_boundary=False)
def _importModule(self, module_name):
return __import__(self._getComponentFullModuleName(module_name),
fromlist=[self._document_class._getDynamicModuleNamespace()],
level=0)
module_name = self._getComponentFullModuleName(module_name)
module = __import__(
module_name,
fromlist=[self._document_class._getDynamicModuleNamespace()],
level=0)
self.assertTrue(module_name in sys.modules)
return module
def testValidateInvalidateDelete(self):
"""
......@@ -1997,6 +2002,10 @@ def bar(*args, **kwargs):
self.assertHasAttribute(module, 'bar')
self.assertEqual(module.bar(), 'BarTestImportedVersionedComponentOnly')
# Now check that the alias module on the top-level package is properly
# created when importing it
self._importModule(imported_reference)
def testVersionPriority(self):
"""
Check whether Version priorities properly works by adding and removing
......
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