Skip to content

Commit

Permalink
correct for gui
Browse files Browse the repository at this point in the history
  • Loading branch information
GayLaurent committed Jan 27, 2016
1 parent 567fd06 commit 1dfec67
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
12 changes: 8 additions & 4 deletions lucterios/framework/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
14 changes: 11 additions & 3 deletions lucterios/install/lucterios_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions lucterios/install/lucterios_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ def center(root, size=None):
class InstanceEditor(Toplevel):

def __init__(self):

Toplevel.__init__(self)
self.focus_set()
self.grab_set()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 = []
Expand All @@ -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:
Expand Down

0 comments on commit 1dfec67

Please sign in to comment.