|
@@ -3,6 +3,7 @@ import sys
|
|
import warnings
|
|
import warnings
|
|
from importlib import import_module
|
|
from importlib import import_module
|
|
|
|
|
|
|
|
+from celery.datastructures import AttributeDict
|
|
from celery.loaders.base import BaseLoader
|
|
from celery.loaders.base import BaseLoader
|
|
from celery.exceptions import NotConfigured
|
|
from celery.exceptions import NotConfigured
|
|
|
|
|
|
@@ -25,18 +26,6 @@ def wanted_module_item(item):
|
|
return not item.startswith("_")
|
|
return not item.startswith("_")
|
|
|
|
|
|
|
|
|
|
-class Settings(dict):
|
|
|
|
-
|
|
|
|
- def __getattr__(self, key):
|
|
|
|
- try:
|
|
|
|
- return self[key]
|
|
|
|
- except KeyError:
|
|
|
|
- raise AttributeError(key)
|
|
|
|
-
|
|
|
|
- def __setattr_(self, key, value):
|
|
|
|
- self[key] = value
|
|
|
|
-
|
|
|
|
-
|
|
|
|
class Loader(BaseLoader):
|
|
class Loader(BaseLoader):
|
|
"""The default loader.
|
|
"""The default loader.
|
|
|
|
|
|
@@ -45,7 +34,7 @@ class Loader(BaseLoader):
|
|
"""
|
|
"""
|
|
|
|
|
|
def setup_settings(self, settingsdict):
|
|
def setup_settings(self, settingsdict):
|
|
- settings = Settings(DEFAULT_SETTINGS, **settingsdict)
|
|
|
|
|
|
+ settings = AttributeDict(DEFAULT_SETTINGS, **settingsdict)
|
|
installed_apps = set(list(DEFAULT_SETTINGS["INSTALLED_APPS"]) + \
|
|
installed_apps = set(list(DEFAULT_SETTINGS["INSTALLED_APPS"]) + \
|
|
list(settings.INSTALLED_APPS))
|
|
list(settings.INSTALLED_APPS))
|
|
settings.INSTALLED_APPS = tuple(installed_apps)
|
|
settings.INSTALLED_APPS = tuple(installed_apps)
|
|
@@ -56,24 +45,6 @@ class Loader(BaseLoader):
|
|
|
|
|
|
return settings
|
|
return settings
|
|
|
|
|
|
- def import_from_cwd(self, module, imp=import_module):
|
|
|
|
- """Import module, but make sure it finds modules
|
|
|
|
- located in the current directory.
|
|
|
|
-
|
|
|
|
- Modules located in the current directory has
|
|
|
|
- precedence over modules located in ``sys.path``.
|
|
|
|
- """
|
|
|
|
- cwd = os.getcwd()
|
|
|
|
- if cwd in sys.path:
|
|
|
|
- return imp(module)
|
|
|
|
- sys.path.insert(0, cwd)
|
|
|
|
- try:
|
|
|
|
- return imp(module)
|
|
|
|
- finally:
|
|
|
|
- try:
|
|
|
|
- sys.path.remove(cwd)
|
|
|
|
- except ValueError:
|
|
|
|
- pass
|
|
|
|
|
|
|
|
def read_configuration(self):
|
|
def read_configuration(self):
|
|
"""Read configuration from ``celeryconfig.py`` and configure
|
|
"""Read configuration from ``celeryconfig.py`` and configure
|