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

Side by Side Diff: sitescripts/web.py

Issue 5744805892063232: Issue 1374 - Don`t hardcode web handlers for multiplexer (Closed)
Patch Set: Created Sept. 15, 2014, 9:58 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
« sitescripts/utils.py ('K') | « sitescripts/utils.py ('k') | 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-2014 Eyeo GmbH 4 # Copyright (C) 2006-2014 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,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details. 13 # GNU General Public License for more details.
14 # 14 #
15 # You should have received a copy of the GNU General Public License 15 # You should have received a copy of the GNU General Public License
16 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 16 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
17 17
18 import base64 18 import base64
19 import importlib
19 from sitescripts.utils import get_config 20 from sitescripts.utils import get_config
20 21
21 handlers = {} 22 handlers = {}
22 authenticated_users = {} 23 authenticated_users = {}
23 24
24 def url_handler(url): 25 def url_handler(url):
25 def decorator(func): 26 def decorator(func):
26 registerUrlHandler(url, func) 27 registerUrlHandler(url, func)
27 return func 28 return func
28 return decorator 29 return decorator
(...skipping 20 matching lines...) Expand all
49 expected_username = config.get(config_section, "basic_auth_username") 50 expected_username = config.get(config_section, "basic_auth_username")
50 expected_password = config.get(config_section, "basic_auth_password") 51 expected_password = config.get(config_section, "basic_auth_password")
51 if username == expected_username and password == expected_password: 52 if username == expected_username and password == expected_password:
52 return f(environ, start_response) 53 return f(environ, start_response)
53 54
54 realm = get_config().get("DEFAULT", "basic_auth_realm") 55 realm = get_config().get("DEFAULT", "basic_auth_realm")
55 start_response("401 UNAUTHORIZED", 56 start_response("401 UNAUTHORIZED",
56 [("WWW-Authenticate", 'Basic realm="%s"' % realm)]) 57 [("WWW-Authenticate", 'Basic realm="%s"' % realm)])
57 return "" 58 return ""
58 59
59 import subscriptions.web.fallback 60 for module in set(get_config().options("multiplexer")) - set(get_config().defaul ts()):
60 import crashes.web.submitCrash 61 importlib.import_module(module)
61 import reports.web.submitReport
62 import reports.web.updateReport
63 import reports.web.showDigest
64 import reports.web.showUser
65 import formmail.web.formmail
66 import crawler.web.crawler
67 import urlfixer.web.submitData
68 import extensions.web.downloads
OLDNEW
« sitescripts/utils.py ('K') | « sitescripts/utils.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld