X-Git-Url: https://git.openstreetmap.org./osqa.git/blobdiff_plain/6cea0592c2d7522b7e6501ebe52368618f92d58c..577d5301bc90f71afdcd82ca62bd711351dbfa73:/forum/modules/__init__.py diff --git a/forum/modules/__init__.py b/forum/modules/__init__.py index f8e0fd1..6942c91 100644 --- a/forum/modules/__init__.py +++ b/forum/modules/__init__.py @@ -1,26 +1,7 @@ -import os import types import logging -from forum.utils.mixed import Proxy - -MODULES_PACKAGE = 'forum_modules' - -MODULE_LIST = [] - - -def init_modules_engine(site_src_root, disabled_modules): - modules_folder = os.path.join(site_src_root, MODULES_PACKAGE) - - MODULE_LIST.extend(filter(lambda m: getattr(m, 'CAN_USE', True), [ - __import__('forum_modules.%s' % f, globals(), locals(), ['forum_modules']) - for f in os.listdir(modules_folder) - if os.path.isdir(os.path.join(modules_folder, f)) and - os.path.exists(os.path.join(modules_folder, "%s/__init__.py" % f)) and - not f in disabled_modules - ])) - - get_modules_folder.value = modules_folder +from django.conf import settings def get_modules_folder(): return get_modules_folder.value @@ -28,22 +9,17 @@ def get_modules_folder(): def get_modules_script(script_name): all = [] - for m in MODULE_LIST: + for m in settings.MODULE_LIST: if hasattr(m, script_name): all.append(getattr(m, script_name)) continue try: all.append(__import__('%s.%s' % (m.__name__, script_name), globals(), locals(), [m.__name__])) - except ImportError, e: - #print repr(type(e)) + m.__name__ + ":" + str(e) - pass - except: - import traceback - msg = "Error importing %s from module %s: \n %s" % ( - script_name, m, traceback.format_exc() - ) - logging.error(msg) + except Exception, e: + if isinstance(e, ImportError) and str(e).endswith(script_name): + continue + logging.exception("Error importing %s from module %s", script_name, m) return all