Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: cms/utils.py

Issue 29328208: Noissue - [CMS] Avoid overzealous catching of KeyError during conversion (Closed)
Patch Set: Go back to using try... catch Created Sept. 21, 2015, 11:03 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # coding: utf-8 1 # coding: utf-8
2 2
3 # This file is part of the Adblock Plus web scripts, 3 # This file is part of the Adblock Plus web scripts,
4 # Copyright (C) 2006-2015 Eyeo GmbH 4 # Copyright (C) 2006-2015 Eyeo GmbH
5 # 5 #
6 # Adblock Plus is free software: you can redistribute it and/or modify 6 # Adblock Plus is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License version 3 as 7 # it under the terms of the GNU General Public License version 3 as
8 # published by the Free Software Foundation. 8 # published by the Free Software Foundation.
9 # 9 #
10 # Adblock Plus is distributed in the hope that it will be useful, 10 # Adblock Plus is distributed in the hope that it will be useful,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 localefile = params["config"].get("locale_overrides", page) 42 localefile = params["config"].get("locale_overrides", page)
43 params["localedata"] = source.read_locale(params["locale"], localefile) 43 params["localedata"] = source.read_locale(params["locale"], localefile)
44 44
45 if params["config"].has_option("general", "siteurl"): 45 if params["config"].has_option("general", "siteurl"):
46 if site_url_override: 46 if site_url_override:
47 params["site_url"] = site_url_override 47 params["site_url"] = site_url_override
48 else: 48 else:
49 params["site_url"] = params["config"].get("general", "siteurl") 49 params["site_url"] = params["config"].get("general", "siteurl")
50 50
51 try: 51 try:
52 converter = converters[format](params) 52 converter = converters[format]
Wladimir Palant 2015/09/21 11:18:02 I think this variable is better called converter_c
kzar 2015/09/21 11:23:15 Done.
53 except KeyError: 53 except KeyError:
54 raise Exception("Page %s uses unknown format %s" % (page, format)) 54 raise Exception("Page %s uses unknown format %s" % (page, format))
55 55
56 converter = converter(params)
57
56 # Note: The converter might change some parameters so we can only read in 58 # Note: The converter might change some parameters so we can only read in
57 # template data here. 59 # template data here.
58 params["templatedata"] = source.read_template(params["template"]) 60 params["templatedata"] = source.read_template(params["template"])
59 61
60 defaultlocale = params["config"].get("general", "defaultlocale") 62 defaultlocale = params["config"].get("general", "defaultlocale")
61 params["defaultlocale"] = defaultlocale 63 params["defaultlocale"] = defaultlocale
62 64
63 locales = [ 65 locales = [
64 l 66 l
65 for l in source.list_locales() 67 for l in source.list_locales()
(...skipping 13 matching lines...) Expand all
79 81
80 return params 82 return params
81 83
82 def process_page(source, locale, page, format=None, site_url_override=None, 84 def process_page(source, locale, page, format=None, site_url_override=None,
83 localized_string_callback=None): 85 localized_string_callback=None):
84 return TemplateConverter( 86 return TemplateConverter(
85 get_page_params(source, locale, page, format, 87 get_page_params(source, locale, page, format,
86 site_url_override, localized_string_callback), 88 site_url_override, localized_string_callback),
87 key="templatedata" 89 key="templatedata"
88 )() 90 )()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld