From 1dfec67cda346a2cfe8909fffa4e8a89ddb5e2c2 Mon Sep 17 00:00:00 2001 From: Laurent GAY Date: Wed, 27 Jan 2016 11:56:17 +0100 Subject: [PATCH] correct for gui --- lucterios/framework/settings.py | 12 ++++++++---- lucterios/install/lucterios_admin.py | 14 +++++++++++--- lucterios/install/lucterios_gui.py | 7 ++++--- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/lucterios/framework/settings.py b/lucterios/framework/settings.py index dc2ab43..fdc2080 100644 --- a/lucterios/framework/settings.py +++ b/lucterios/framework/settings.py @@ -132,20 +132,24 @@ def get_locale_lang(): 'LANGUAGES': DEFAULT_LANGUAGES, } +LOCALE_PATH = [] + def _get_locale_pathes(appli_name, addon_modules): - local_path = [] + def add_locale_path(new_path): + if new_path not in LOCALE_PATH: + LOCALE_PATH.append(new_path) module_lang_list = [ "lucterios.CORE", 'lucterios.framework', "lucterios.install", appli_name] if addon_modules is not None: module_lang_list.extend(addon_modules) for module_lang_item in module_lang_list: module_path = import_module(module_lang_item).__path__[0] - local_path.append(join(module_path, 'locale', '')) + add_locale_path(join(module_path, 'locale', '')) for subdir in os.listdir(module_path): if isdir(join(module_path, subdir)) and isdir(join(module_path, subdir, 'locale')): - local_path.append(join(module_path, subdir, 'locale', '')) - return tuple(local_path) + add_locale_path(join(module_path, subdir, 'locale', '')) + return tuple(LOCALE_PATH) def _get_extra(module_to_setup): diff --git a/lucterios/install/lucterios_admin.py b/lucterios/install/lucterios_admin.py index abb0768..d5d32b8 100755 --- a/lucterios/install/lucterios_admin.py +++ b/lucterios/install/lucterios_admin.py @@ -49,9 +49,10 @@ def get_module_title(module_name): try: current_mod = import_module(module_name) - return six.text_type(getattr(current_mod, '__title__')()) + result = getattr(current_mod, '__title__')() except AttributeError: - return "??? (%s)" % module_name + result = "??? (%s)" % module_name + return six.text_type(result) def get_package_list(): @@ -786,10 +787,17 @@ def main(): def setup_from_none(): from lucterios.framework.settings import fill_appli_settings import types + lct_modules = [] + glob = LucteriosGlobal() + _, mod_applis, mod_modules = glob.installed() + for mod_item in mod_applis: + lct_modules.append(mod_item[0]) + for mod_item in mod_modules: + lct_modules.append(mod_item[0]) module = types.ModuleType("default_setting") setattr(module, '__file__', "") setattr(module, 'SECRET_KEY', "default_setting") - fill_appli_settings("lucterios.standard", None, module) + fill_appli_settings("lucterios.standard", lct_modules, module) sys.modules["default_setting"] = module os.environ.setdefault("DJANGO_SETTINGS_MODULE", "default_setting") import django diff --git a/lucterios/install/lucterios_gui.py b/lucterios/install/lucterios_gui.py index fd3b1f3..779c738 100644 --- a/lucterios/install/lucterios_gui.py +++ b/lucterios/install/lucterios_gui.py @@ -139,7 +139,6 @@ def center(root, size=None): class InstanceEditor(Toplevel): def __init__(self): - Toplevel.__init__(self) self.focus_set() self.grab_set() @@ -235,7 +234,8 @@ def appli_selection(self, event): appli_id = list(self.applis[VALUES]).index(self.applis.get()) luct_glo = LucteriosGlobal() current_inst_names = luct_glo.listing() - appli_root_name = sorted(self.mod_applis)[appli_id][0].split('.')[-1] + appli_root_name = sorted( + self.mod_applis)[appli_id][0].split('.')[-1] default_name_idx = 1 while appli_root_name + six.text_type(default_name_idx) in current_inst_names: default_name_idx += 1 @@ -324,6 +324,7 @@ def execute(self, instance_name=None): self.typedb[VALUES] = ["SQLite", "MySQL", "PostgreSQL"] lct_glob = LucteriosGlobal() _, self.mod_applis, mod_modules = lct_glob.installed() + self.mod_applis.sort(key=lambda item: get_module_title(item[0])) self.modules.delete(0, END) self.module_data = [] module_list = [] @@ -335,7 +336,7 @@ def execute(self, instance_name=None): self.modules.insert(END, module_title) self.module_data.append(module_name) appli_list = [] - for mod_appli_item in sorted(self.mod_applis): + for mod_appli_item in self.mod_applis: appli_list.append(get_module_title(mod_appli_item[0])) self.applis[VALUES] = appli_list if instance_name is not None: