Index: cms/utils.py |
=================================================================== |
--- a/cms/utils.py |
+++ b/cms/utils.py |
@@ -17,17 +17,16 @@ |
from .converters import converters, TemplateConverter |
def process_page(source, locale, page, format, site_url_override=None): |
params = { |
"source": source, |
"template": "default", |
"locale": locale, |
- "title": "title", |
"page": page, |
"pagedata": source.read_page(page, format), |
"config": source.read_config(), |
} |
localefile = page |
if params["config"].has_option("locale_overrides", page): |
localefile = params["config"].get("locale_overrides", page) |
@@ -44,17 +43,21 @@ def process_page(source, locale, page, f |
except KeyError: |
raise Exception("Page %s uses unknown format %s" % (page, format)) |
# Note: The converter might change some parameters so we can only read in |
# template data here. |
params["templatedata"] = source.read_template(params["template"]) |
template_converter = TemplateConverter(params, key="templatedata") |
- params["available_locales"] = sorted( |
- filter( |
- lambda locale: source.has_locale(locale, localefile), |
- source.list_locales() |
- ) |
- ) |
+ params["defaultlocale"] = params["config"].get("general", "defaultlocale") |
+ |
+ params["available_locales"] = [ |
+ locale |
+ for locale in source.list_locales() |
+ if source.has_locale(locale, localefile) |
+ ] |
+ if params["defaultlocale"] not in params["available_locales"]: |
+ params["available_locales"].append(params["defaultlocale"]) |
+ params["available_locales"].sort() |
Sebastian Noack
2015/03/12 20:33:46
Four inline lookups for "available_locales" and th
Wladimir Palant
2015/03/12 20:57:02
Not sure it really makes the code better here but
Sebastian Noack
2015/03/12 21:08:19
Much better. Thanks.
|
params["head"], params["body"] = converter() |
return template_converter() |