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

Delta Between Two Patch Sets: sitescripts/web.py

Issue 5177883412660224: Issue 2234 - Add a WSGI controller to collect email addresses for the Adblock Browser iOS launch (Closed)
Left Patch Set: Refactored Created April 24, 2015, 2:16 p.m.
Right Patch Set: URL-encode language before inserting into URL Created April 28, 2015, 10:50 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« sitescripts/submit_email/web/submit_email.py ('K') | « sitescripts/utils.py ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 content_length = int(environ['CONTENT_LENGTH']) 84 content_length = int(environ['CONTENT_LENGTH'])
85 except (KeyError, ValueError): 85 except (KeyError, ValueError):
86 content_length = None 86 content_length = None
87 if content_length is None or content_length < 0: 87 if content_length is None or content_length < 0:
88 return send_simple_response(start_response, 411) 88 return send_simple_response(start_response, 411)
89 89
90 raw_data = parse_qsl(environ['wsgi.input'].read(content_length)) 90 raw_data = parse_qsl(environ['wsgi.input'].read(content_length))
91 try: 91 try:
92 data = {k.decode('utf-8'): v.decode('utf-8') for k, v in raw_data} 92 data = {k.decode('utf-8'): v.decode('utf-8') for k, v in raw_data}
93 except UnicodeDecodeError: 93 except UnicodeDecodeError:
94 return send_simple_response(start_response, 400, 'Form data must use UTF-8 ') 94 return send_simple_response(start_response, 400, 'Invalid form data encodi ng')
Wladimir Palant 2015/04/24 22:50:48 'Invalid form data encoding'?
Sebastian Noack 2015/04/27 13:39:10 Not sure why this message would be any better, but
95 95
96 return func(environ, start_response, data) 96 return func(environ, start_response, data)
97 97
98 return wrapper 98 return wrapper
99 99
100 def multiplex(environ, start_response): 100 def multiplex(environ, start_response):
101 try: 101 try:
102 path = environ["PATH_INFO"] 102 path = environ["PATH_INFO"]
103 try: 103 try:
104 handler = handlers[path] 104 handler = handlers[path]
105 except KeyError: 105 except KeyError:
106 handler = handlers[re.sub(r"[^/]+$", "", path)] 106 handler = handlers[re.sub(r"[^/]+$", "", path)]
107 except KeyError: 107 except KeyError:
108 start_response("404 Not Found", [("Content-Type", "text/plain")]) 108 start_response("404 Not Found", [("Content-Type", "text/plain")])
109 return ["Not Found"] 109 return ["Not Found"]
110 110
111 return handler(environ, start_response) 111 return handler(environ, start_response)
112 112
113 for module in set(get_config().options("multiplexer")) - set(get_config().defaul ts()): 113 for module in set(get_config().options("multiplexer")) - set(get_config().defaul ts()):
114 module_path = get_config().get("multiplexer", module) 114 module_path = get_config().get("multiplexer", module)
115 if module_path: 115 if module_path:
116 imp.load_source(module, module_path) 116 imp.load_source(module, module_path)
117 else: 117 else:
118 importlib.import_module(module) 118 importlib.import_module(module)
LEFTRIGHT

Powered by Google App Engine
This is Rietveld