Index: sitescripts/web.py |
diff --git a/sitescripts/web.py b/sitescripts/web.py |
index dc4509b22a295b660d9e357e0f4ea64e773e3519..c0bfd577955e13d51956b7eeab62cdc251513355 100644 |
--- a/sitescripts/web.py |
+++ b/sitescripts/web.py |
@@ -20,6 +20,7 @@ import imp |
import importlib |
import re |
import httplib |
+import urllib |
from urlparse import parse_qsl |
from sitescripts.utils import get_config |
@@ -38,6 +39,15 @@ def registerUrlHandler(url, func): |
raise Exception('A handler for url %s is already registered' % url) |
handlers[url] = func |
+# https://www.python.org/dev/peps/pep-0333/#url-reconstruction |
kzar
2015/10/08 12:06:37
I realised this function should probably live in s
|
+def request_path(environ, include_query=True): |
+ path = urllib.quote(environ.get("SCRIPT_NAME", "") + |
+ environ.get("PATH_INFO", "")) |
+ query_string = environ.get("QUERY_STRING", "") |
+ if query_string and include_query: |
+ path += "?" + urllib.quote(query_string) |
+ return path |
+ |
def basic_auth(config_section = "DEFAULT"): |
def decorator(function): |
def authenticating_wrapper(environ, start_response): |