Преглед на файлове

Fixes bug in celery.utils.find_module

Ask Solem преди 14 години
родител
ревизия
4ba2b68e9e
променени са 3 файла, в които са добавени 7 реда и са изтрити 3 реда
  1. 4 1
      celery/loaders/default.py
  2. 1 1
      celery/tests/test_app/test_loaders.py
  3. 2 1
      celery/utils/__init__.py

+ 4 - 1
celery/loaders/default.py

@@ -19,13 +19,16 @@ class Loader(BaseLoader):
     def setup_settings(self, settingsdict):
         return AttributeDict(settingsdict)
 
+    def find_module(self, module):
+        return find_module(module)
+
     def read_configuration(self):
         """Read configuration from :file:`celeryconfig.py` and configure
         celery and Django so it can be used by regular Python."""
         configname = os.environ.get("CELERY_CONFIG_MODULE",
                                      DEFAULT_CONFIG_MODULE)
         try:
-            find_module(configname)
+            self.find_module(configname)
         except ImportError:
             warnings.warn(NotConfigured(
                 "No %r module found! Please make sure it exists and "

+ 1 - 1
celery/tests/test_app/test_loaders.py

@@ -201,7 +201,7 @@ class TestDefaultLoader(unittest.TestCase):
 
         class _Loader(default.Loader):
 
-            def import_from_cwd(self, name):
+            def find_module(self, name):
                 raise ImportError(name)
 
         with catch_warnings(record=True) as log:

+ 2 - 1
celery/utils/__init__.py

@@ -379,6 +379,7 @@ def cwd_in_path():
 
 
 def find_module(module, path=None, imp=None):
+    """Version of :func:`imp.find_module` supporting dots."""
     if imp is None:
         imp = importlib.import_module
     with cwd_in_path():
@@ -386,7 +387,7 @@ def find_module(module, path=None, imp=None):
             last = None
             parts = module.split(".")
             for i, part in enumerate(parts[:-1]):
-                path = imp(part).__path__
+                path = imp(".".join(parts[:i+1])).__path__
                 last = _imp.find_module(parts[i+1], path)
             return last
         return _imp.find_module(module)