OLD | NEW |
1 # This file is part of the Adblock Plus web scripts, | 1 # This file is part of the Adblock Plus web scripts, |
2 # Copyright (C) 2006-present eyeo GmbH | 2 # Copyright (C) 2006-present eyeo GmbH |
3 # | 3 # |
4 # Adblock Plus is free software: you can redistribute it and/or modify | 4 # Adblock Plus is free software: you can redistribute it and/or modify |
5 # it under the terms of the GNU General Public License version 3 as | 5 # it under the terms of the GNU General Public License version 3 as |
6 # published by the Free Software Foundation. | 6 # published by the Free Software Foundation. |
7 # | 7 # |
8 # Adblock Plus is distributed in the hope that it will be useful, | 8 # Adblock Plus is distributed in the hope that it will be useful, |
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
(...skipping 21 matching lines...) Expand all Loading... |
32 registerUrlHandler(url, func) | 32 registerUrlHandler(url, func) |
33 return func | 33 return func |
34 return decorator | 34 return decorator |
35 | 35 |
36 | 36 |
37 def registerUrlHandler(url, func): | 37 def registerUrlHandler(url, func): |
38 if url in handlers: | 38 if url in handlers: |
39 raise Exception('A handler for url %s is already registered' % url) | 39 raise Exception('A handler for url %s is already registered' % url) |
40 handlers[url] = func | 40 handlers[url] = func |
41 | 41 |
42 # https://www.python.org/dev/peps/pep-0333/#url-reconstruction | |
43 | |
44 | 42 |
45 def request_path(environ, include_query=True): | 43 def request_path(environ, include_query=True): |
46 path = urllib.quote(environ.get('SCRIPT_NAME', '') + | 44 path = urllib.quote(environ.get('SCRIPT_NAME', '') or |
47 environ.get('PATH_INFO', '')) | 45 environ.get('PATH_INFO', '')) |
48 query_string = environ.get('QUERY_STRING', '') | 46 query_string = environ.get('QUERY_STRING', '') |
49 if query_string and include_query: | 47 if query_string and include_query: |
50 path += '?' + urllib.quote(query_string) | 48 path += '?' + urllib.quote(query_string) |
51 return path | 49 return path |
52 | 50 |
53 | 51 |
54 def basic_auth(config_section='DEFAULT'): | 52 def basic_auth(config_section='DEFAULT'): |
55 def decorator(function): | 53 def decorator(function): |
56 def authenticating_wrapper(environ, start_response): | 54 def authenticating_wrapper(environ, start_response): |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 | 125 |
128 return handler(environ, start_response) | 126 return handler(environ, start_response) |
129 | 127 |
130 | 128 |
131 for module in set(get_config().options('multiplexer')) - set(get_config().defaul
ts()): | 129 for module in set(get_config().options('multiplexer')) - set(get_config().defaul
ts()): |
132 module_path = get_config().get('multiplexer', module) | 130 module_path = get_config().get('multiplexer', module) |
133 if module_path: | 131 if module_path: |
134 imp.load_source(module, module_path) | 132 imp.load_source(module, module_path) |
135 else: | 133 else: |
136 importlib.import_module(module) | 134 importlib.import_module(module) |
OLD | NEW |