From bacd63be6caa51f043122995e9b4c9ee421536a5 Mon Sep 17 00:00:00 2001 From: age Date: Sun, 25 Nov 2007 09:21:03 +0000 Subject: [PATCH] fixed the lang.sort fix --- src/cryptobox/core/settings.py | 12 +++++++++++- src/cryptobox/web/dataset.py | 3 +-- src/cryptobox/web/sites.py | 3 +-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/cryptobox/core/settings.py b/src/cryptobox/core/settings.py index da4cbf2..54f0437 100644 --- a/src/cryptobox/core/settings.py +++ b/src/cryptobox/core/settings.py @@ -583,7 +583,7 @@ Details = string(min=1, default="/var/log/cryptobox-server/cryptobox.log") [WebSettings] Stylesheet = string(min=1) -Languages = list(min=1,default=list("en")) +Languages = listOfLanguages(default="en") [Programs] cryptsetup = fileExecutable(default="/sbin/cryptsetup") @@ -624,6 +624,7 @@ class CryptoBoxSettingsValidator(validate.Validator): self.functions["fileExecutable"] = self.check_file_executable self.functions["fileWriteable"] = self.check_file_writeable self.functions["listOfExistingDirectories"] = self.check_existing_directories + self.functions["listOfLanguages"] = self.list_languages def check_directory_exists(self, value): @@ -682,6 +683,15 @@ class CryptoBoxSettingsValidator(validate.Validator): result.append(dir_path) return result + def list_languages(self, langs): + """Return languages as a list. + """ + if not langs: + raise validate.VdtValueError("no language specified") + if not isinstance(langs, list): + langs = [langs] + return langs + class MiscConfigFile: """all other config files (e.g. a ssl certificate) to be stored""" diff --git a/src/cryptobox/web/dataset.py b/src/cryptobox/web/dataset.py index 75eb2a2..72a5219 100644 --- a/src/cryptobox/web/dataset.py +++ b/src/cryptobox/web/dataset.py @@ -57,8 +57,7 @@ class WebInterfaceDataset(dict): for key in self.keys(): if key.startswith("Data.Languages."): del self[key] - langs = [] - langs.append(self.cbox.prefs["WebSettings"]["Languages"][:]) + langs = self.cbox.prefs["WebSettings"]["Languages"][:] langs.sort() for (index, lang) in enumerate(langs): try: diff --git a/src/cryptobox/web/sites.py b/src/cryptobox/web/sites.py index cd96522..7d3c6c1 100644 --- a/src/cryptobox/web/sites.py +++ b/src/cryptobox/web/sites.py @@ -458,8 +458,7 @@ class WebInterfaceSites: 3. languages defined in the config file """ ## start with the configured language order - lang_order = [] - lang_order.append(self.cbox.prefs["WebSettings"]["Languages"][:]) + lang_order = self.cbox.prefs["WebSettings"]["Languages"][:] self.cbox.log.debug( "updating language preferences (default: %s)" % str(lang_order)) ## put the preferred browser language in front