OLD | NEW |
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 imp |
19 import importlib | 20 import importlib |
20 from sitescripts.utils import get_config | 21 from sitescripts.utils import get_config |
21 | 22 |
22 handlers = {} | 23 handlers = {} |
23 authenticated_users = {} | 24 authenticated_users = {} |
24 | 25 |
25 def url_handler(url): | 26 def url_handler(url): |
26 def decorator(func): | 27 def decorator(func): |
27 registerUrlHandler(url, func) | 28 registerUrlHandler(url, func) |
28 return func | 29 return func |
(...skipping 22 matching lines...) Expand all Loading... |
51 expected_password = config.get(config_section, "basic_auth_password") | 52 expected_password = config.get(config_section, "basic_auth_password") |
52 if username == expected_username and password == expected_password: | 53 if username == expected_username and password == expected_password: |
53 return f(environ, start_response) | 54 return f(environ, start_response) |
54 | 55 |
55 realm = get_config().get("DEFAULT", "basic_auth_realm") | 56 realm = get_config().get("DEFAULT", "basic_auth_realm") |
56 start_response("401 UNAUTHORIZED", | 57 start_response("401 UNAUTHORIZED", |
57 [("WWW-Authenticate", 'Basic realm="%s"' % realm)]) | 58 [("WWW-Authenticate", 'Basic realm="%s"' % realm)]) |
58 return "" | 59 return "" |
59 | 60 |
60 for module in set(get_config().options("multiplexer")) - set(get_config().defaul
ts()): | 61 for module in set(get_config().options("multiplexer")) - set(get_config().defaul
ts()): |
61 importlib.import_module(module) | 62 module_path = get_config().get("multiplexer", module) |
| 63 if module_path: |
| 64 imp.load_source(module, module_path) |
| 65 else: |
| 66 importlib.import_module(module) |
OLD | NEW |